[GCC 4.0 PATCH] devfs_vnops.c
Craig Rodrigues
rodrigc at crodrigues.org
Wed May 25 21:48:22 PDT 2005
On Wed, May 25, 2005 at 11:44:52PM -0400, Andrew R. Reiter wrote:
> Is this a GCC-ism or a standards related issue that 4.0 now addresses?
This is a standards issue that GCC 4.0 addresses, which GCC 3.4.2
did not (newer versions of the GCC 3.4.x tree might address is
but I haven't checked). In 6.2.2 paragraph 7 of the ISO C standard,
"If, within a translation unit, the same identifier appears with both
internal and external linkage, the behavior is undefined."
So, if you have:
extern struct foo bar;
static struct foo bar = { ..... };
This is illegal. When the compiler hits the first line,
there was no previous declaration of "struct foo bar", so
the linkage of "struct foo bar" defaults to external linkage.
However, the next line declares "struct foo bar" to have
internal linkage.
--
Craig Rodrigues
rodrigc at crodrigues.org
More information about the freebsd-current
mailing list