This is weird.
In the linkfile I have
_build_type = 1;
and sure enough in the .map file I see
0x0000000000000001 _build_type = 0x1
but this code
extern char _build_type;
strcat((char *)PAGE_BODY, "<br>Build: ");
if ( _build_type == 0 )
{
strcat((char *)PAGE_BODY, "v0");
}
else if ( _build_type == 1 )
{
strcat((char *)PAGE_BODY, "v1");
}
always sees it as zero. Confirmed by stepping through it.
I have also tried int instead of char - doesn't pick up a value at all. I am wondering whether every value in a linkfile is actually implicitly an address, so one can't do this?
But then this type of construct works
extern char _s_nonboot_data;
extern char _e_nonboot_data;
extern char _si_nonboot_data;
memcpy(&_s_nonboot_data, &_si_nonboot_data, &_e_nonboot_data - &_s_nonboot_data);
and "obviously" 0 and 1 are also valid addresses.
Obviously I could have a .h file with a #define in it, etc, but for other reasons I am trying to select a text string based on a symbol defined 0/1 in the linkfile. I can build two different versions of the project which are very similar but have different linkfiles.