From: Kotrba L. <LK...@cs...> - 2004-04-02 16:18:24
|
Hello, From the snapshot 2.4.1 (20040310) of sdcc I found a problem with determination of size of an array inside a struct. In the examples below there are 2 definitions of structure containing array named case_table1 and case_table2. The difference between them is only in the specification of size of the array char_pf_struct rows[]; case_table1 does not specify the size and does not work correctly- it takes only one element of the array. On other hand if we specify the size of the array as in case_table2, all works fine. Can anybody help with this problem? Ladislav Kotrba //>sdcc -v //SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.4.1 (Mar 10 2004) (MINGW32) typedef struct { unsigned char pattern; void (*pf) (void); } char_pf_struct ; typedef struct { unsigned char num_row; char_pf_struct rows[]; } case_pattern_struct ; extern void foo1(void); extern void foo2(void); //Definition below generated warning: excess elements in array initializer after `case_table1' // and struct includes only elements 2, 0x40, foo1 code case_pattern_struct case_table1 = { 2, { {0x40, /*01000000B*/ foo1}, {0x50, /*01010000B*/ foo2} } }; //This definition is OK //struct includes elements 2, 0x40, *foo1, 0x50, *foo2 code struct { unsigned char num_row; char_pf_struct rows[2];} case_table2 = { 2, { {0x40, /*01000000B*/ foo1}, {0x50, /*01010000B*/ foo2} } }; //-------------------------------------------------------------------; // Proc. def. ; //-------------------------------------------------------------------; void foo1(void) {} void foo2(void) {} |