_info 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "config.h"
  2. #include <stdio.h>
  3. #include <string.h>
  4. /**
  5. * structeq - bitwise comparison of structs.
  6. *
  7. * This is a replacement for memcmp, which checks the argument types are the
  8. * same.
  9. *
  10. * License: CC0 (Public domain)
  11. * Author: Rusty Russell <rusty@rustcorp.com.au>
  12. *
  13. * Example:
  14. * #include <ccan/structeq/structeq.h>
  15. * #include <ccan/build_assert/build_assert.h>
  16. * #include <assert.h>
  17. *
  18. * struct mydata {
  19. * int start, end;
  20. * };
  21. *
  22. * int main(void)
  23. * {
  24. * struct mydata a, b;
  25. *
  26. * // No padding in struct, otherwise this doesn't work!
  27. * BUILD_ASSERT(sizeof(a) == sizeof(a.start) + sizeof(a.end));
  28. *
  29. * a.start = 100;
  30. * a.end = 101;
  31. *
  32. * b.start = 100;
  33. * b.end = 101;
  34. *
  35. * // They are equal.
  36. * assert(structeq(&a, &b));
  37. *
  38. * b.end++;
  39. * // Now they are not.
  40. * assert(!structeq(&a, &b));
  41. *
  42. * return 0;
  43. * }
  44. */
  45. int main(int argc, char *argv[])
  46. {
  47. /* Expect exactly one argument */
  48. if (argc != 2)
  49. return 1;
  50. if (strcmp(argv[1], "depends") == 0) {
  51. return 0;
  52. }
  53. return 1;
  54. }