Zero size struct
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I noticed that when compiled with GCC 4.6 sizeof(Foo) is 0 and sizeof(Bar) is 1. For some reason adding an empty array into an empty structure made its size 0. I thought that the sizes of both structures must be the same. What is going on here? struct Foo { char x[]; }; struct Bar {}; 回答1: Neither struct declaration is allowed by the C standard. 6.7.2.1 (8) in n1570: And paragraph 18 in the same section: As a special case, the last element of a structure with more than one named member (emphasis mine) Flexible array members are not allowed