]> git.ozlabs.org Git - ccan/blob - ccan/structeq/structeq.h
structeq: new module.
[ccan] / ccan / structeq / structeq.h
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 /**
7  * structeq - are two structures bitwise equal (including padding!)
8  * @a: a pointer to a structure
9  * @b: a pointer to a structure of the same type.
10  *
11  * If you *know* a structure has no padding, you can memcmp them.  At
12  * least this way, the compiler will issue a warning if the structs are
13  * different types!
14  */
15 #define structeq(a, b) \
16         (memcmp((a), (b), sizeof(*(a)) + 0 * sizeof((a) == (b))) == 0)
17 #endif /* CCAN_STRUCTEQ_H */