DJ Delorie <[EMAIL PROTECTED]> writes:
[...] | If it's OK to have the enums in a header, provided you can't *use* them... | | enum { | #ifdef TVQ_AUTHORITATIVE_ENUMS | TVQ_FOO1, | TVQ_FOO2, | TVQ_FOO3, | TVQ_NUM_ENTRIES, | #endif | TVQ_INT_SIZER = 32767; | } TheValQuux; | | This won't stop a suitably enthusiastic programmer from getting to | them anyway, but that's always the case. Furthermore, that does not stop an enthusiastic programmer from feeding the interface functions with the wrong values if he is supposed to convert between integers and enums. That is a far more important problem that trying to prevent using the names. If you provide the names, then you have control over what they mean and there is no incitation to cast things, therefore there is more chance to get things right and less chance to get the horrible bugs one would like to prevent by making the names inaccessible. The names are not the problem. | Or... | | #ifndef TVG_ENUM | #define TVG_ENUM(X) DONT_USE_ME_TVG_##x | #endif | enum { | TVG_ENUM(FOO1), | TVG_ENUM(FOO2), | TVG_ENUM(FOO3), | } TheValQuux; | | With the "authority" suitably defining TVG_ENUM. | | Of course, these are all just hacks to hide the enumerations. -- Gaby