Possible Duplicate:
zero length arrays vs. pointers編譯錯誤,而用C
一些新的編譯器扔了編譯錯誤,下面情況
struct test {
int length;
char data[0];
};
int main(void)
{
char string[20] = {0};
struct test *t;
//Some code
memcpy(string, t->data, 19); //Compilation error
}
但是,如果我不喜歡這本得到解決。
memcpy(string, &(t->data[0]), 19);
爲什麼一些新的編譯器正在執行此限制的任何原因?
編輯,以糾正錯誤
,如果你認爲它會請考慮有助於包含您從編譯器逐字逐句獲得的實際錯誤。 – unwind
你在x86上使用gcc嗎? – pedr0
這種情況發生在icc(intel c編譯器) – nkumar