C++ 标准 - 如何处理 "array of unknown bound of T"

标签 c++ arrays standards

我对这段代码的工作感到困惑:

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/

相关文章:

c++ - 错误 : request for member '..' in '..' which is of non-class type

时间:2019-02-08 标签:c++coutuncastedmemory(void)

java - 检查一个数组的所有元素是否与另一个数组的所有元素具有相同的值

java - 在数组索引处查找字符串? java

c - 指针表示

java - JAXB 区分大小写的类生成

c++ - 使用 write() 复制二进制文件,复制文件的大小增加

c++ - Windows API 中的 InvalidateRect,Charles Petzold checker4.c 程序

c - 从函数返回错误的数组值

c - EOF 保证为 -1 吗?