Harbison/Steele's C reference says that the end of a full declarator is a sequence point. But what is a full declarator?
"A full declarator is a declarator that is not part of another declarator"
... what?
So as an example, would it be guaranteed by the C standard that int i = 0, *j = &i
stores the memory address with the value of the variable i
in the pointer j
?
In other words, is the int i = 0
part a full declarator?
A declarator is the part of a declaration that specifies the name to introduce into the program. It can include modifiers such as * (pointer-to) and any of the Microsoft calling-convention keywords. Microsoft Specific. In this declarator, C Copy.
A declaration means (in C) that you are telling the compiler about type, size and in case of function declaration, type and size of its parameters of any variable, or user-defined type or function in your program. No space is reserved in memory for any variable in case of the declaration.
No, you are mixing declarations and declarators.
Let me quote pieces of the C grammar from the standard:
declaration:
declaration-specifiers init-declarator-list[opt] ;
init-declarator-list:
init-declarator-list , init-declarator
init-declarator:
declarator
declarator = initializer
And then:
declarator:
pointer[opt] direct-declarator
direct-declarator:
identifier
( declarator )
....
TL;DR: int i = 0;
is a declaration. The i
part is a declarator.
The part about full declarators is clear if you have, for example, pointers. This line:
int *p[3] = { 0 };
is a declaration. The part *p[3]
is the full declarator, but p[3]
and p
are also (non-full) declarators.
And asking your first question, yes, int i = 0, *j = &i;
is perfectly fine, because there are two full declarators: i
and *j
. There is a sequence point at the end of each full declarator plus another sequence point at the end of each initializer. You could even write void *p = &p;
and it would be just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With