更新时间:2023-11-10 12:17:46
下面的语句
extern char arr[];
是具有外部链接的声明,并说改编
有一个类型字符
的阵列,它意味着该改编
可以有一个不完整的类型。
is a declaration with external linkage, and says that arr
has a type of array of char
, which implies that arr
can have an incomplete type.
据6.7声明(n1570):
According to "6.7 Declarations" (n1570):
7,该对象的类型应
通过在其声明月底完成,或者通过其init声明符结束时,如果它有一个
初始化;在功能参数(包括在原型)的情况下,它是调整
型(见6.7.6.3),该需要是完整的。
7 If an identifier for an object is declared with no linkage, the type for the object shall be complete by the end of its declarator, or by the end of its init-declarator if it has an initializer; in the case of function parameters (including in prototypes), it is the adjusted type (see 6.7.6.3) that is required to be complete.
和改编[7]
等于 *(ARR + 7)
和 ARR
需要有一种类型的指针来完成对象类型,而的改编
类型将从字符到指针字符
,在这种情况下。
And arr[7]
equals *(arr + 7)
, and arr
need to have a type of "pointer to complete object type", and the type of arr
will be converted from "array of char
" to "pointer to char
" in this case.
据6.3.2.1左值,数组和功能指示符(n1570):
According to "6.3.2.1 Lvalues, arrays, and function designators" (n1570):
3除非它是的sizeof
运算符的操作数,则 _Alignof
运营商,或
一元&安培;
运营商,或者是用于初始化数组,有一个前pression一个字符串文字
类型''类型的数组''转换为类型指向数组对象的初始元素,而不是一个左值'指向类型为'一个前pression。
3 Except when it is the operand of the
sizeof
operator, the_Alignof
operator, or the unary&
operator, or is a string literal used to initialize an array, an expression that has type ‘‘array of type’’ is converted to an expression with type ‘‘pointer to type’’ that points to the initial element of the array object and is not an lvalue.