Array size depending on symbol address
- From: usenet@xxxxxxx
- Date: 29 Nov 2005 20:25:53 GMT
Hello,
I am running my code on an embedded platform without OS. I have defined some
data in a section called .eeprom. The section is defined by the linker
script and starts at address zero. The symbol __eeprom_end is defined by the
linker script as well, and lies at the end of this section. The address of
__eeprom_end is thus equal to the number of bytes in the .eeprom section.
My problem : I want to declare an array in .bss with the same size of this
section. My naive approch was :
extern void *_eeprom;
char eeprom_shadow[(int)&_eeprom_end];
This fails miserably, ofcourse : the compiler doesn't know the address of
__eeprom before the linker is done, so it can not declare the array.
Is there a trick to allocate the memory for this array at compile time ? I'd
rather not use malloc() and friends, since I am working on a platform with a
very small amount of memory, and don't like using dynamic memory here.
Thanks,
--
:wq
^X^Cy^K^X^C^C^C^C
.
- Follow-Ups:
- Re: Array size depending on symbol address
- From: Skarmander
- Re: Array size depending on symbol address
- From: Gordon Burditt
- Re: Array size depending on symbol address
- Prev by Date: Re: sizeof a union
- Next by Date: Re: direct string manuplation not working
- Previous by thread: PayPal Opportunity
- Next by thread: Re: Array size depending on symbol address
- Index(es):
Relevant Pages
|