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 #if defined(SDCC_hc08)
33 const char *string1 = "\x00\x01";
34 const char string2[] = "\x00\x01";
37 #pragma disable_warning 147 //no warning about excess initializers (W_EXCESS_INITIALIZERS)
38 //array will be truncated but warning will be suppressed
39 //if truncation is incorrect, other ASSERTs will fail with high probability
40 char STORAGE trunc[2] = {'a', 'b', 'c'};
43 char STORAGE array[5] = {'a', 'b', 'c'};
61 struct x STORAGE teststruct[5] = {
62 { 10, { 1, 2, 3, 4, 5} },
73 struct y STORAGE incompletestruct = {
81 ASSERT(string1[1] == '\x01');
82 ASSERT(string2[1] == '\x01');
84 ASSERT(array[2] == 'c');
85 ASSERT(array[4] == 0);
88 ASSERT(g[1].a == 'y');
90 ASSERT(g[2].a == 'z');
94 ASSERT(teststruct[0].b[1] == 2);
95 ASSERT(teststruct[0].b[5] == 0);
96 ASSERT(teststruct[1].b[0] == 11);
97 ASSERT(teststruct[4].b[9] == 0);
99 ASSERT(sizeof(teststruct[2].a) == 2);
100 ASSERT(sizeof(teststruct[1].b) == 10);
101 ASSERT(sizeof(teststruct[1]) == 12);
102 ASSERT(sizeof(teststruct) == 60);
105 ASSERT(incompletestruct.a == 10);
106 ASSERT(incompletestruct.b[0] == 1);
107 ASSERT(incompletestruct.b[4] == 5);
109 ASSERT(sizeof(incompletestruct) == sizeof(struct y));
110 ASSERT(sizeof(incompletestruct) == offsetof(struct y, b));
111 ASSERT(sizeof(incompletestruct) == offsetof(struct x, b));