This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

hidden enum constants (Was: Compiling GCC with g++: a report)


Zack Weinberg <zack@codesourcery.com> wrote:

>>> This doesn't do what I want at all.  The goal is to make the *symbolic
>>> enumeration constants* inaccessible to most code.
>>
> ...
>> 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.
>
> Ooh, I like this one for enum machine_mode.

I think this is an ODR failure for C++ and I suspect program-at-a-time would
flag it with an error. So even this solution to hide enum constants (a
legitimate design request) does not appear to be C++ compatible to me.
-- 
Giovanni Bajo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]