1 /* Check basic behaviour of "flexible array members"
5 #if defined(__SUNPRO_C) || defined(__GNUC__)
9 #if !defined(__SUNPRO_C) && (!defined(__GNUC__) || (defined(__GNUC__) && __GNUC__ >= 3))
10 /* flexible array members not supported by gcc < 3 compiler
11 and seems not to be supported on SunPro C compiler */
18 struct str1 s11
= { 1, {2, 3} };
19 struct str1 s12
= { 4, {5, 6, 7} }; /* different size */
23 testFlexibleArray1(void)
25 #if !defined(__SUNPRO_C) && (!defined(__GNUC__) || (defined(__GNUC__) && __GNUC__ >= 3))
26 /* flexible array members not supported by gcc < 3 compiler
27 and seems not to be supported on SunPro C compiler */
29 ASSERT(sizeof(s11
) == 1);
30 /* test allocation size */
31 #if !defined(PORT_HOST) && !defined(__SDCC_pic14) // Linker changes data order
32 ASSERT((char *) &s12
- (char *) &s11
== 1 + 4);
38 /* test initialisation with string */
40 #if !defined(__SUNPRO_C) && (!defined(__GNUC__) || (defined(__GNUC__) && __GNUC__ >= 3))
41 /* flexible array members not supported by gcc < 3 compiler
42 and seems not to be supported on SunPro C compiler */
49 struct str2 s21
= { 1, "sdcc" };
50 struct str2 s22
= { 2, "sdcc is great" }; /* different size */
54 testFlexibleArray2(void)
56 #if !defined(__SUNPRO_C) && (!defined(__GNUC__) || (defined(__GNUC__) && __GNUC__ >= 3))
57 /* flexible array members not supported by gcc < 3 compiler
58 and seems not to be supported on SunPro C compiler */
60 ASSERT(sizeof(s21
) == 2);
61 /* test allocation size */
62 #if !defined(PORT_HOST) && !defined(__SDCC_pic14) // Linker changes data order
63 ASSERT((char *) &s22
- (char *) &s21
== 2 + 5);