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 };
Be very careful - here be cross-platform compatibility dragons! It's one thing to get it to compile; possibly as much again to get the compiled code to work! Byte ordering and data sizes are two of the fiercest dragons. Anyway, back at your question, does the C166 compiler have an option which forces int to default to unsigned? My Borland manual specifically includes an example like yours, and the Keil C51 manual specifically mentions negative values in enums. Your example gives no error in C51 v6.03, but the Keil compilers are not all equal!