7g-struct-byte-word-field.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* -*-comment-start: "//";comment-end:""-*-
  2. * GNU Mes --- Maxwell Equations of Software
  3. * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. *
  5. * This file is part of GNU Mes.
  6. *
  7. * GNU Mes is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * GNU Mes is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <mes/lib.h>
  21. #include <inttypes.h>
  22. #include <string.h>
  23. struct option
  24. {
  25. char const *name;
  26. uint8_t index;
  27. uint16_t flags;
  28. int barf;
  29. };
  30. int
  31. main ()
  32. {
  33. struct option h = { "help", 0, 10, 1 };
  34. struct option o = { "output", 1, 11, 1 };
  35. struct option v = { "version", 0, 0, 1 };
  36. if (strcmp (h.name, "help"))
  37. return 1;
  38. if (h.index != 0)
  39. return 2;
  40. if (h.flags != 10)
  41. return 3;
  42. struct option *p = &o;
  43. if (strcmp (p->name, "output"))
  44. return 4;
  45. if (p->index != 1)
  46. return 5;
  47. if (p->flags != 11)
  48. return 6;
  49. p = &v;
  50. v.index = 2;
  51. p->flags = 12;
  52. if (v.index != 2)
  53. return 7;
  54. if (v.flags != 12)
  55. return 8;
  56. return 0;
  57. }