structeq.h 567 B

1234567891011121314151617
  1. /* CC0 (Public domain) - see LICENSE file for details */
  2. #ifndef CCAN_STRUCTEQ_H
  3. #define CCAN_STRUCTEQ_H
  4. #include <string.h>
  5. /**
  6. * structeq - are two structures bitwise equal (including padding!)
  7. * @a: a pointer to a structure
  8. * @b: a pointer to a structure of the same type.
  9. *
  10. * If you *know* a structure has no padding, you can memcmp them. At
  11. * least this way, the compiler will issue a warning if the structs are
  12. * different types!
  13. */
  14. #define structeq(a, b) \
  15. (memcmp((a), (b), sizeof(*(a)) + 0 * sizeof((a) == (b))) == 0)
  16. #endif /* CCAN_STRUCTEQ_H */