Re: [GCC 4.0 PATCH] devfs_vnops.c

From: Craig Rodrigues <rodrigc_at_crodrigues.org>
Date: Thu, 26 May 2005 00:48:24 -0400
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
Received on Thu May 26 2005 - 02:48:22 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:35 UTC