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're interpreting the standard better than my memory did, Mike. The address itself would have been eligible for an initializer, but the cast turned it into an implementation-defined thing, which the implementation can rightfully refuse to allow in an initializer.

    And of course, as soon as keywords like 'near' or 'far' become involved, you're well outside the region where any language standard would
    apply in the first place.

Reply
  • You're interpreting the standard better than my memory did, Mike. The address itself would have been eligible for an initializer, but the cast turned it into an implementation-defined thing, which the implementation can rightfully refuse to allow in an initializer.

    And of course, as soon as keywords like 'near' or 'far' become involved, you're well outside the region where any language standard would
    apply in the first place.

Children
No data