这是合法的C++吗?
struct foo
{
int a[100];
int b[sizeof(a) / sizeof(a[0])];
};
Run Code Online (Sandbox Code Playgroud)
GCC 4.6接受它,但MSVC 2012没有.看起来它对我来说应该没问题,但谷歌搜索没有帮助,我不知道在标准中的哪个位置.
MSVC 2012提供以下输出:
error C2327: 'foo::a' : is not a type name, static, or enumerator
error C2065: 'a' : undeclared identifier
error C2070: ''unknown-type'': illegal sizeof operand
warning C4200: nonstandard extension used : zero-sized array in struct/union
Run Code Online (Sandbox Code Playgroud)