我有一個SDCC的問題。我的代碼(我試圖從另一個編譯器中移植)使用具有靈活數組成員的結構。然而,當我嘗試編譯下面的代碼:sdcc不接受代碼
/** header of string list */
typedef struct {
int nCount;
int nMemUsed;
int nMemAvail;
} STRLIST_HEADER;
/** string list entry data type */
typedef struct {
int nLen;
char str[];
} STRLIST_ENTRY;
/** string list data type */
typedef struct {
STRLIST_HEADER header;
STRLIST_ENTRY entry[];
} STRLIST; // By the way, this is the line the error refers to.
int main()
{
return 0;
}
SDCC提供了以下錯誤:
$ sdcc -mz80 -S --std-c99 test.c
test.c:18: warning 186: invalid use of structure with flexible array member
test.c:18: error 200: field 'entry' has incomplete type
是怎麼回事?這段代碼在gcc中編譯得很好,更不用說我使用的其他z80編譯器了。
編輯:我發現this SDCC bug這似乎是相關的。有人可以解釋它是否是和如何?
非常好。 SDCC文檔最多是窮人,而GCC接受該聲明有助於進一步混淆我。非常感謝你! – thirtythreeforty