Herbert Rosenau said:
Herbert said:
(e-mail address removed) wrote:
declaration
lovecreatesbeauty wrote:
venky wrote:
main() {
int x; /* it declaration or defination??*/
}
int x; is always a definition;
extern int x; may be a declaration.
The top-poster says it's a declaration, which it is,
[un-snipped] but it is also a definition (not a "defination").
No, it is at block level, so it is clearly a _definition_ of an
uninitialised variable of type int named x on storage class auto.
What exactly was your point? You left out the part of jmcgill's message
where he states it is a definition, so that you could tell him that it is a
definition? He clearly already knows that!
Learn the difference between a declaration and a definition.
I suggest you do so yourself.
Here's what jmcgill wrote:
| The top-poster says it's a declaration, which it is, but it is also a
| definition (not a "defination").
|
| The declaration of the function in its definition in the example should
| be according to one of the the prototypes int main(void); or int
| main(int, char**);
You misleadingly quoted only part of that: "The top-poster says it's a
declaration, which it is,".
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;99)
-- for an enumeration constant or typedef name, is the (only)
declaration of the identifier.
All definitions are declarations. jmcgill was right. You were wrong.