* structeq - bitwise comparison of structs.
*
* This is a replacement for memcmp, which checks the argument types are the
- * same.
+ * same, and takes into account padding in the structure. When there is no
+ * padding, it becomes a memcmp at compile time (assuming a
+ * constant-optimizing compiler).
*
- * License: CC0 (Public domain)
+ * License: BSD-MIT
* Author: Rusty Russell <rusty@rustcorp.com.au>
*
* Example:
* struct mydata {
* int start, end;
* };
+ * // Defines mydata_eq(a, b)
+ * STRUCTEQ_DEF(mydata, 0, start, end);
*
* int main(void)
* {
* struct mydata a, b;
*
- * // No padding in struct, otherwise this doesn't work!
- * BUILD_ASSERT(sizeof(a) == sizeof(a.start) + sizeof(a.end));
- *
* a.start = 100;
* a.end = 101;
*
- * b.start = 100;
- * b.end = 101;
- *
* // They are equal.
- * assert(structeq(&a, &b));
+ * assert(mydata_eq(&a, &b));
*
* b.end++;
* // Now they are not.
- * assert(!structeq(&a, &b));
+ * assert(!mydata_eq(&a, &b));
*
* return 0;
* }
return 1;
if (strcmp(argv[1], "depends") == 0) {
+ printf("ccan/build_assert\n");
+ printf("ccan/cppmagic\n");
return 0;
}