avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] eeprom issue


From: David Kelly
Subject: Re: [avr-gcc-list] eeprom issue
Date: Fri, 11 May 2007 18:13:26 -0500

On Fri, May 11, 2007 at 09:12:58AM +1200, Gavin Jackson wrote:
Steve

Since the .h file is pulled into each .c file, you would end up with two declarations for temp_ee, hence the two 0x0A values in your ee.hex file.
If you remove the static keyword the compiler should complain that you
have two global variables with the same name. The correct place to
declare the variable would be in the .c file and not in the header.

Yes, if it is supposed to be static then its supposed to be hidden from
other modules so its not proper to put in a header which is reused
unless each and every re-use is supposed to have its own private copy.

I prefix most everything in headers with "extern", then repeat the
definition without extern in one and only one .c file, but in one that
does include the header. If the two definitions do not match the
compiler complains. Meanwhile all other modules have access to the
variable.

In The Bad Old Days many defined all variables in headers which were
included many times in the project. Compiler/linkers typically
eliminated the multiple definitions. Things worked, but were asking for
trouble.

I expect "extern static" is a contradictory statement which would cause
gcc to bellyache. Haven't tried it, just guessing.

--
David Kelly N4HHE, address@hidden
========================================================================
Whom computers would destroy, they must first drive mad.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]