繁体   English   中英

标准中哪里说下面的 typedef 是有效的?

[英]Where in the standard does it say that the typedef below is valid?

g++clang++编译这个片段:

typedef int int3[];
int3 i { 0, 1, 2 };

但是标准中哪里说上面的数组typedef声明是有效的?

您如何推断int3[]int[]的“同义词”?

但是标准中哪里说上面的 typedef 声明是有效的?

这是有效的。 按照标准:

9.2.4 typedef 说明符 [dcl.typedef]

1 - 包含 decl 说明符 typedef 的声明声明了以后可用于命名基本 (6.8.2) 或复合 (6.8.3) 类型的标识符。 [...]

在哪里:

6.8.3 复合类型 [basic.compound]

1 - 可以通过以下方式构造复合类型:

— (1.1) arrays 给定类型的对象,9.3.4.5;

[...]


您如何推断int3[]int[]的“同义词”?

声明定义明确,包括具有未知边界的 arrays:

9.3.4.5 Arrays [dcl.array]

[...]

5 - 任何形式的“cv-qualifier-seq array of NU”都被调整为“array of N cv-qualifier-seq U”,同样适用于“array of unknown bound of U”。

[...]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM