lkml.org 
[lkml]   [2002]   [Jan]   [3]   [last100]   RSS Feed
Views: [more markup]   [less markup]   [headers]   [forward]  
 
Messages in this thread
/
DateWed, 2 Jan 2002 23:42:26 -0800
From"H . J . Lu" <>
SubjectRe: Extern variables in *.c files
On Wed, Jan 02, 2002 at 11:19:29PM -0800, Andrew Morton wrote:
> 
> Alas, it doesn't quite work as we'd like:
> 
> akpm-1:/home/akpm> cat a.c
> int a;
> 
> main()
> {}
> akpm-1:/home/akpm> cat b.c
> extern char a;
> 
> int b()
> {return a;}
> akpm-1:/home/akpm> gcc -fno-common -Wl,--warn-common a.c b.c
> akpm-1:/home/akpm> 
> 
> No warnings emitted.  If b.c doesn't use `extern' it will fail
> to link because of -fno-common.
> 
> What we'd *like* to happen is for the linker to determine that
> the `extern char' and the `int' declarations are a mismatch.
> Maybe the object file doesn't have the size info for `extern'
> variables.   The compiler emits it though.
> 

Compile doesn't emit the size info for

extern char a;

One way to fix it is to remove

extern char a;

and put

extern int a;

in a header file which is included by everyone.


H.J.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 11:15    [W:0.164 / U:0.330 seconds]
©2003-2008 Jasper Spaans