1 /* Check basic behaviour of "flexible array members"
5 #if !defined __GNUC__ || __GNUC__ >= 3
6 /* flexible array members not supported by gcc < 3 */
13 struct str1 s11 = { 1, {2, 3} };
14 struct str1 s12 = { 4, {5, 6, 7} }; /* different size */
18 testFlexibleArray1(void)
20 #if !defined __GNUC__ || __GNUC__ >= 3
21 /* flexible array members not supported by gcc < 3 */
23 ASSERT(sizeof(s11) == 1);
24 /* test allocation size */
25 #if ! defined(PORT_HOST)
26 ASSERT((char *) &s12 - (char *) &s11 == 1 + 4);
32 /* test initialisation with string */
34 #if !defined __GNUC__ || __GNUC__ >= 3
35 /* flexible array members not supported by gcc < 3 */
42 struct str2 s21 = { 1, "sdcc" };
43 struct str2 s22 = { 2, "sdcc is great" }; /* different size */
47 testFlexibleArray2(void)
49 #if !defined __GNUC__ || __GNUC__ >= 3
50 /* flexible array members not supported by gcc < 3 */
52 ASSERT(sizeof(s21) == 2);
53 /* test allocation size */
54 #if ! defined(PORT_HOST)
55 ASSERT((char *) &s22 - (char *) &s21 == 2 + 5);