不,等等,忍受我...
No, wait, bear with me...
VLA 一直是 GCC 的扩展,但它们被 C99 采用:
VLAs were always a GCC extension, but they were adopted by C99:
[C99: 6.7.5.2/4]: 如果大小不存在,则数组类型为不完整的类型.如果大小是 * 而不是表达式,则数组类型是未指定大小的可变长度数组类型,它只能在具有函数原型作用域的声明中使用;这样的数组仍然是完整的类型.如果大小为整数常量表达式并且元素类型具有已知的常量大小,数组类型不是变长数组类型;否则,数组类型是变长数组类型.
[C99: 6.7.5.2/4]:If the size is not present, the array type is an incomplete type. If the size is * instead of being an expression, the array type is a variable length array type of unspecified size, which can only be used in declarations with function prototype scope; such arrays are nonetheless complete types. If the size is an integer constant expression and the element type has a known constant size, the array type is not a variable length array type; otherwise, the array type is a variable length array type.
C99 也称为 ISO/IEC 9899:1999.
现在:
[C++11: 1.1/2]: C++ 是一种基于通用编程语言使用 ISO/IEC 9899:1999 中规定的 C 编程语言(以下简称C标准).除了C 提供的工具,C++ 提供额外的数据类型、类、模板、异常、命名空间、运算符重载、函数名超载、引用、免费的商店管理操作符,以及额外的图书馆设施.
[C++11: 1.1/2]:C++ is a general purpose programming language based on the C programming language as specified in ISO/IEC 9899:1999 (hereinafter referred to as the C standard). In addition to the facilities provided by C, C++ provides additional data types, classes, templates, exceptions, namespaces, operator overloading, function name overloading, references, free store management operators, and additional library facilities.
那么 C++11 不应该也有 VLA 吗?
这种留有余地的措辞并不意味着 C99 中的所有内容都在 C++11 中.您引用的只是介绍性文字.
That leeway wording doesn't mean that any and everything in C99 is in C++11. What you quoted is just introductory text.
这篇关于C++ 是否支持变长数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
编译器如何处理编译时分支?What do compilers do with compile-time branching?(编译器如何处理编译时分支?)
我可以使用 if (pointer) 而不是 if (pointer != NULL) 吗Can I use if (pointer) instead of if (pointer != NULL)?(我可以使用 if (pointer) 而不是 if (pointer != NULL) 吗?)
在 C/C++ 中检查空指针Checking for NULL pointer in C/C++(在 C/C++ 中检查空指针)
比较运算符的数学式链接-如“if((5<j<=1))&quMath-like chaining of the comparison operator - as in, quot;if ( (5lt;jlt;=1) )quot;(比较运算符的数学式链接-如“if((5<j<=1)))
“if constexpr()"之间的区别与“if()"Difference between quot;if constexpr()quot; Vs quot;if()quot;(“if constexpr()之间的区别与“if())
C++,'if' 表达式中的变量声明C++, variable declaration in #39;if#39; expression(C++,if 表达式中的变量声明)