On Mon, 20 Aug 2007 14:31:47 -0400, in comp.lang.c , Kenneth Brody
<ke******@spamcop.netwrote:
>Mark McIntyre wrote:
>>
Such objects have 'no linkage' and you can't have two of them in the
same scope. See 6.2.2 of the Standard.
Does that mean that this should be valid?
void foo(void)
{
static int *p;
int i;
extern int *p = &i;
}
My compiler doesn't allow it.
Interesting - I think that this ought to be allowed by 6.2.2p4,
though I'm happy to be corrected. Is this a C89 vs C99 thing?
"For an identifier declared with the storage-class specifier extern in
a scope in which a prior declaration of that identifier is visible, if
the prior declaration specifies internal or external linkage, the
linkage of the identifier at the later declaration is the same as the
linkage specified at the prior declaration. If no prior declaration is
visible, or if the prior declaration specifies no linkage, then the
identifier has external linkage."
--
Mark McIntyre
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan