Is it a definition or a declaration?
This question already has an answer here:
It's a declaration. It declares the type struct foo
.
(C99, 6.7p5) "A declaration specifies the interpretation and attributes of a set of identifiers. A definition of an identifier is a declaration for that identifier that:
— for an object, causes storage to be reserved for that object;
— for a function, includes the function body;101)
— for an enumeration constant or typedef name, is the (only) declaration of the identifier."
Your understanding is correct. Your code example is a declaration of a type. In 'C' you can declare a type and immediately use it to define a variable.
So your example is a pure declaration.
And here is an example of declaration+variable definition:
struct foo {
char name[10];
char title[10];
int salary;
} var;
链接地址: http://www.djcxy.com/p/40626.html
上一篇: 在C语言头文件中
下一篇: 它是一个定义还是一个声明?