We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'm currently attempting to modify an automatic code generation package (designed to run with MSVC/C++, WATCOM C/C++ and Borland C) to autogenerate software compilable with the Keil CA166 package. Of the standard files which have to be included into the code, one of them contains the lines...
enum { COMPLEX_INHERITED = -1, COMPLEX_NO, COMPLEX_YES };
For instance if it is used in array subscripting, the negative value would be an error. Just curious, but why would negative array subscripts be an error? For example:
char stack [100]; /* Create a stack */ char *p; /* Create a stack pointer */ p = &stack [50]; /* Initialize the stack pointer */ p [0] = 12; /* Put stuff onto the stack */ p [-1] = 13; p [-2] = 14;
You got me Jon. I started shooting my keyboard off and got called on it. As for the problem described though, I can not get the following to compile without generating the warning "C118 enum constant: signed value out of range": enum { TEST_A1 = -1, TEST_A2 }; If you change the initial value to -2, it compiles. If you add member TEST_A3 after TEST_A2 and leave the initial value at -2, now it won't compile. If the only member is TEST_A1 and it is initialized to -1, it compiles. It appears the problem is experienced when the enum list crosses from a negative number to zero.
The solution with my compiler (C166 v4.06) seems to be to explicitly equate the value which should be zero to zero.