The following code generates a this error when compiled: C51 COMPILER V6.02 - SN: XXXXX-XXXXX COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 1999 *** ERROR C221 IN LINE 7 OF QUEUE_I.H: non-constant case/dim expression
const unsigned char code BUF_SIZE = 40; BYTE Qbuf[BUF_SIZE];
#define BUF_SIZE 40
"I was surprised since other compilers compiled the const version without errors (GNU X-Tools for one)." I you sure that they were all 'C' compilers - not C++? Also, are you sure that you tried this in their strict ANSI mode? "In addition, I've read Good Style practices that recommended using const rather than #define" Again, are you sure they were specifically for 'C' - rather than C++, or any other language?
Both probably weren't strict ANSI C, but the compiler wasn't a C++ compiler nor was the style guideline for C++.