我对这段代码的工作感到困惑:
struct S
{
char c[];
};
S s;
根据 C++ 标准,第 8.3.4 章:
"If the constant expression is omitted, the type of the identifier of D is “derived-declarator-type-list array of unknown bound of T”, an incomplete object type."
但我无法弄清楚“不完整的对象类型”是如何变得完整的。
感谢您的帮助!
最佳答案
您说过您发布的代码将在 VS10 中编译。关闭语言扩展,然后就不会了。项目>属性>C/C++>语言>禁用语言扩展=是。这是编译,因为您正在使用特定于 MS 的 C++ 语言扩展。
简而言之,根据标准,您的代码不应该编译。
关于C++ 标准 - 如何处理 "array of unknown bound of T",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3786632/