This question is related to GCC says "syntax error before numeric constant" in generated header file from bison and I'm getting an error concerning enum (I think), but the answers there only gave the reason for why one might see the error, "error: syntax error before numeric constant." Unless I glossed over it, I didn't see any good solutions to avoid this problem (except of course to simply rename our enumeration constants). Thus, my question is: besides simply renaming enum constants to avoid this naming conflict, are there other (preferable) ways to get around this problem? Using namespaces does not seem to work.
UPDATE (for namespaces): I get this error:
enum.cpp:5:5: error: expected identifier before numeric constant
enum.cpp:5:5: error: expected ‘}’ before numeric constant
enum.cpp:5:5: error: expected unqualified-id before numeric constant
enum.cpp:7:1: error: expected declaration before ‘}’ token
from this program:
#include <sys/ioctl.h>
namespace mine {
enum test {
NCC
};
}
int main(int argc, char** argv)
{
return 0;
}
Note, I get the same error when compiling this program:
#define NCC 5
namespace mine {
enum test {
NCC
};
}
int main(int argc, char** argv)
{
return 0;
}