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