3 storage: idata, xdata, code,
6 #define STORAGE {storage}
10 #define FLEXARRAY (__GNUC__ >= 3)
11 //since g fails on GCC 2.95.4 on alpha and I don't know how to detect alpha...
12 #define TEST_G (__GNUC__ >= 3)
20 typedef unsigned int size_t;
21 #define offsetof(s,m) (size_t)&(((s *)0)->m)
23 #if defined(PORT_HOST) || defined(SDCC_z80) || defined(SDCC_gbz80)
29 const char *string1 = "\x00\x01";
30 const char string2[] = "\x00\x01";
33 #pragma disable_warning 147 //no warning about excess initializers (W_EXCESS_INITIALIZERS)
34 //array will be truncated but warning will be suppressed
35 //if truncation is incorrect, other ASSERTs will fail with high probability
36 char STORAGE trunc[2] = {'a', 'b', 'c'};
39 char STORAGE array[5] = {'a', 'b', 'c'};
57 struct x STORAGE teststruct[5] = {
58 { 10, { 1, 2, 3, 4, 5} },
69 struct y STORAGE incompletestruct = {
77 ASSERT(string1[1] == '\x01');
78 ASSERT(string2[1] == '\x01');
80 ASSERT(array[2] == 'c');
81 ASSERT(array[4] == 0);
84 ASSERT(g[1].a == 'y');
86 ASSERT(g[2].a == 'z');
90 ASSERT(teststruct[0].b[1] == 2);
91 ASSERT(teststruct[0].b[5] == 0);
92 ASSERT(teststruct[1].b[0] == 11);
93 ASSERT(teststruct[4].b[9] == 0);
95 ASSERT(sizeof(teststruct[2].a) == 2);
96 ASSERT(sizeof(teststruct[1].b) == 10);
97 ASSERT(sizeof(teststruct[1]) == 12);
98 ASSERT(sizeof(teststruct) == 60);
101 ASSERT(incompletestruct.a == 10);
102 ASSERT(incompletestruct.b[0] == 1);
103 ASSERT(incompletestruct.b[4] == 5);
105 ASSERT(sizeof(incompletestruct) == sizeof(struct y));
106 ASSERT(sizeof(incompletestruct) == offsetof(struct y, b));
107 ASSERT(sizeof(incompletestruct) == offsetof(struct x, b));