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: Arnim Littek
Subject: RE: [avr-gcc-list] eeprom issue
Date: Fri, 11 May 2007 09:34:10 +1200

There's a pretty widely used  hacro to avoid duplicate invocations of
header files:

#ifndef  __STDEF_H__
#define __STDEF_H__

/* contents of header file here

#endif /* end __STDEF_H__ */

Arnim.



>>> "Gavin Jackson" <address@hidden> 11/05/2007 9:12 a.m. >>>
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.

You'll find that your static char temp is also using two different
memory locations, it's just not as easy to see since they're static
and
don't appear in the map file, but check the addresses being used in
the
compiled .c files and you'll see they are at different memory
locations.

Regards

Gavin Jackson
-------------------------------------------
Research & Development Engineer
Tru-Test Limited
PO Box 51078
Pakuranga
Manukau 2140
Auckland, New Zealand
DDI +64 9 978 8757
-------------------------------------------

-----Original Message-----
From: address@hidden 
[mailto:address@hidden On
Behalf
Of Steve Franks
Sent: Friday, 11 May 2007 9:02 a.m.
To: address@hidden 
Subject: [avr-gcc-list] eeprom issue


I think I may have finally found my first legitimate bug!  Then,
again, maybe not:

Anyway, if you have a project with two C/C++ sources, both of which
include the same header, and you have:

static char temp_ee __attribute__((section (".eeprom"))) = 10;

in the header, if you build, you will see 0x0A at two locations in
your ee.hex file.

I don't have an example at the moment, because I had to deliver to a
customer, so naturally, I moved the variable definition to one C file
only, and pointed to the ram value I load it into in the header.

static char temp (w/o the EE attrib) appeared to work fine in the same
header, so it appears to be a unique error to the EE attrib.

If we elevate this to, "yes, it may actually be a bug, Steve's not
just clueless", then I'd be happy to regenerate the example code.
Thought I'd check with y'all first.

Steve


_______________________________________________
AVR-GCC-list mailing list
address@hidden 
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


_______________________________________________
AVR-GCC-list mailing list
address@hidden 
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
WARNING: This email and any attachments may be confidential and/or
privileged. They are intended for the addressee only and are not to be read,
used, copied or disseminated by anyone receiving them in error.  If you are
not the intended recipient, please notify the sender by return email and
delete this message and any attachments.

The views expressed in this email are those of the sender and do not
necessarily reflect the official views of Landcare Research.  

SirTrack
http://www.sirtrack.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++






reply via email to

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