Is it declaration or defination?

H

Herbert Rosenau

[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.

--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!
 
H

Herbert Rosenau

You unfairly snipped part of my message. The definition is also a
declaration.

No, a declaration does not assign memory, a definition does.
Definitions and declarations are clearly different.

--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!
 
H

Harald van =?UTF-8?B?RMSzaw==?=

Herbert 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. "Definition" in this context is defined in n1124 6.7p5,
and it is very clear: it does not allow for /any/ definitions (of
identifiers) that are not also declarations.
 
F

fiocco

Herbert Rosenau said:
No, a declaration does not assign memory, a definition does.
Definitions and declarations are clearly different.

He meant that when you define something, you declare it too, so they are
related
 
K

Keith Thompson

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.
 
G

Guest

Herbert 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.
Here is the thing:
Definitions are also declarations.
(the converse is not true, ofcourse)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top