[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-ppc
Subject:    RE: Compile problems
From:       Randall R Schulz <rrschulz () cris ! com>
Date:       2000-07-10 13:40:00
[Download RAW message or body]


Steve,

At 07:46 -0400 7/10/00, Steve Revilak wrote:
>  > I have been trying to compile some c code and running into problems....
>
>...
>
>>  gcc test1.c test2.c
>>  and I get the following list of errors:
>>  /tmp/cca2PpML.o: In function `main':
>>  /tmp/cca2PpML.o(.text+0x26): undefined reference to `a'
>
>Right.  Because both files are referencing this variable 'a' that isn't
>declared anywhere.  Either get rid of the 'extern' in one of the files
>or create a header file with a declaration for the variable and #include
>it in test1.c and test2.c.

Careful. If the declartion in the .h file is "extern," then the
problem will remain. If the delcaration in the .h file isn't
"extern," then multiple definitions will occur and the linker will
now complain about that unacceptable situation.

The burden is always on the programmer to make sure there is exactly
one defining declaration for all non-local, non-member (or
non-struct-field) variables.

Randall Schulz
Mountain View, CA USA


>--
>Steve Revilak
>revilak@umbsky.cc.umb.edu

** Sent via the linuxppc-user mail list. See http://lists.linuxppc.org/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic