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)
28 #if defined(SDCC_hc08)
32 const char *string1 = "\x00\x01";
33 const char string2[] = "\x00\x01";
36 #pragma disable_warning 147 //no warning about excess initializers (W_EXCESS_INITIALIZERS)
37 //array will be truncated but warning will be suppressed
38 //if truncation is incorrect, other ASSERTs will fail with high probability
39 char STORAGE trunc[2] = {'a', 'b', 'c'};
42 char STORAGE array[5] = {'a', 'b', 'c'};
60 struct x STORAGE teststruct[5] = {
61 { 10, { 1, 2, 3, 4, 5} },
72 struct y STORAGE incompletestruct = {
80 ASSERT(string1[1] == '\x01');
81 ASSERT(string2[1] == '\x01');
83 ASSERT(array[2] == 'c');
84 ASSERT(array[4] == 0);
87 ASSERT(g[1].a == 'y');
89 ASSERT(g[2].a == 'z');
93 ASSERT(teststruct[0].b[1] == 2);
94 ASSERT(teststruct[0].b[5] == 0);
95 ASSERT(teststruct[1].b[0] == 11);
96 ASSERT(teststruct[4].b[9] == 0);
98 ASSERT(sizeof(teststruct[2].a) == 2);
99 ASSERT(sizeof(teststruct[1].b) == 10);
100 ASSERT(sizeof(teststruct[1]) == 12);
101 ASSERT(sizeof(teststruct) == 60);
104 ASSERT(incompletestruct.a == 10);
105 ASSERT(incompletestruct.b[0] == 1);
106 ASSERT(incompletestruct.b[4] == 5);
108 ASSERT(sizeof(incompletestruct) == sizeof(struct y));
109 ASSERT(sizeof(incompletestruct) == offsetof(struct y, b));
110 ASSERT(sizeof(incompletestruct) == offsetof(struct x, b));