c - Error when creating an array with memory addresses -
i have matrix declaration implemented follows:
int var_porcencomun; int var_porceninv; uint32_t pointers[] = { (uint32_t)&var_porcencomun, 9999999, (uint32_t)&var_porceninv, 999999 };
those global variables. code compiles fine.
basically, "pointers" holds address of variable , maximum value supposed hold.
my problem have add matrix new variable, defined uint64_t. although size of pointer in platform 32 bits, i'd have change "pointers" uint64_t, because of size of variable. when do:
uint64_t pointers[] = { (uint64_t)&var_porcencomun, 9999999, (uint64_t)&var_porceninv, 999999 };
i following error:
: error! e1054: expression must constant
why error happening when change "pointers" type?
i'm using watcom 1.3 compiler. gcc , visual studio's have compiled fine code.
globals must initialised constant values. guess watcom don't believe values constants (maybe bad compile-time calculations).
you can try hack compiler (like convert uint32_t, automatic conversion may happen; or bit tricks, none of guaranteed) or move array initialisaion out of static (e.g. moving somehwere init
function call @ beginning of main
).
Comments
Post a Comment