I came across this piece of code. It doesn't give an error, but what exactly does it mean?
int A[]={};
EDIT: I had to edit this post because some of you asked for context, compiler and so on..
I do not know much about compilers but i managed to found the version i'm using "gcc (tdm-1) 4.9.2".
I have tried the code myself and it did run correctly, i was also able to read and write on the array. My question is : What exactly happens when i declare such an array ?
int A[]={};
is illegal in C. Empty initializers are not valid. See C11 draft, 6.7.9 Initialization .
It means nothing, it is not valid C.
C11 6.7.9 states that the two following forms are valid:
{ initializer-list }
{ initializer-list , }
where initializer-list
is defined as one of the following:
designationopt initializer
initializer-list , designationopt initializer
This could either be an assignment expression or a C99 designated initializer. An empty initializer list is not valid syntax.
它定义了一个int
类型的空数组。
You should show some more context, and mention which compiler was being used.
I don't think that code compiles with a standards-compliant compiler, the empty initializer list makes it invalid.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.