]> www.ginac.de Git - cln.git/blob - cmake/modules/CheckTypeAlign.c.in
CLN can be built with CMake
[cln.git] / cmake / modules / CheckTypeAlign.c.in
1 @headers@
2
3 #ifndef HAVE_STDDEF_H
4 /* 
5  * This definition is definitely not standard compliant, but it works
6  * surprisingly well. Also, conforming implementations are supposed
7  * to ship the <stddef.h> file.
8  */
9 #define offsetof(st, m) ((int)((char*)&((st*)(0))->m - (char*)0))
10 #endif
11 #undef KEY
12 #if defined(__i386)
13 # define KEY '_','_','i','3','8','6'
14 #elif defined(__x86_64)
15 # define KEY '_','_','x','8','6','_','6','4'
16 #elif defined(__ppc__)
17 # define KEY '_','_','p','p','c','_','_'
18 #elif defined(__ppc64__)
19 # define KEY '_','_','p','p','c','6','4','_','_'
20 #endif
21
22 #define SIZE (offsetof(struct { char c; @type@ x; }, x))
23 char info_size[] =  {'I', 'N', 'F', 'O', ':', 's','i','z','e','[',
24   ('0' + ((SIZE / 10000)%10)),
25   ('0' + ((SIZE / 1000)%10)),
26   ('0' + ((SIZE / 100)%10)),
27   ('0' + ((SIZE / 10)%10)),
28   ('0' +  (SIZE    % 10)),
29   ']',
30 #ifdef KEY
31   ' ','k','e','y','[', KEY, ']',
32 #endif
33   '\0'};
34
35 #ifdef __CLASSIC_C__
36 int main(argc, argv) int argc; char *argv[];
37 #else
38 int main(int argc, char *argv[])
39 #endif
40 {
41   int require = 0;
42   require += info_size[argc];
43   (void)argv;
44   return require;
45 }