This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compiler Error 143: 'Scalar' : Initialiser is not a constant

#define adr(x) ((word) &(x))
char tmsec[20];

struct par_struct AL[] = {

   //par.nr, lv, ln, eh, adress                         bk, pt,           ft
   {     1,  2,  8,  0, 0,                               ptUSER,       40},
   {     2,  2,  8,  0, 0,                               ptUSER,       41},
   {     3,  2,  1,  0, 0,                               ptUSER,       42},
   {     4,  0,  0,  1, adr(Tmsec),
};

It is a part of a parameter table of about 1500 elements.
When compiling this in C166, I am getting this error when the variable adr(x) is an array with more than 6 elements. In C51 this worked perfect.
I also tried to write directly ((word) &tmsec[0]) instead of adr(tmsec) with the define, but this did not help.

What is the reason that it does not work when "tmsec" is an array with over 6 elements ?

Hope anyone can help..

Joost

Parents
  • "You'll have to cite me chapter and verse of the standard you base that claim on before I agree that the address of an object qualifies as a compile time constant suitable for use as an initializer for a static (non variadic-array) object."

    Surely it must be so - otherwise how would we do tables of function pointers...?

    As well as assigning addresses, the linker also fixes-up references to those addresses; therefore, the compiler can take the address of an object as a copile-time constant.

    Well, that's what I think, anyway... ;-)

Reply
  • "You'll have to cite me chapter and verse of the standard you base that claim on before I agree that the address of an object qualifies as a compile time constant suitable for use as an initializer for a static (non variadic-array) object."

    Surely it must be so - otherwise how would we do tables of function pointers...?

    As well as assigning addresses, the linker also fixes-up references to those addresses; therefore, the compiler can take the address of an object as a copile-time constant.

    Well, that's what I think, anyway... ;-)

Children
No data