kc@rna.UUCP (Kaare Christian) (01/11/90)
In my previous querry, I didn't intend to reignite the enum controversies from the past. In hindsight, I have confused those who might help me to answer my question by building and initializing enum constants using the OR operator. Sorry. (Although that is an issue, it's a bit off my track.) My real problem has to do with const, and how it seems to work differently when applied to enum vs when applied to something fundamental, like int. Because of this, I am almost unable to use const enum types, and that seems a shame, because it makes me either return to #define, or actually store things in variables that needn't take up a storage location. Anyway, consider the following more focused example program: enum EEE { val1 }; // int column enum column int i = 0; EEE e = val1; const int j = 0; const EEE f = val1; const int k = i; const EEE g = e; int l = j; EEE h = f; (No, I don't program in the above style. Its just a demo.) Zortech gives syntax errors (not warnings) for all but the first EEE declaration. In each case the problem is mixing a <const enum EEE> with an <enum EEE>. None of the int declarations are flagged. And, there are other places where ztc doesn't let you mix a const enum with a plain enum, like in passing things to functions. I've become convinced that const enums in ztc are not quite right. Comments, anyone? Kaare Christian kc@rna.rockefeller.edu
comeau@utoday.UUCP (Greg Comeau) (01/12/90)
In article <969@rna.UUCP> kc@rna.UUCP (Kaare Christian) writes: >My real problem has to do with const, and how it seems to work >differently when applied to enum vs when applied to something >fundamental, like int. >I've become convinced that const enums in ztc are not quite right. >Comments, anyone? Yes, your last statement is correct. This is not a C++ 2.0 spec problem but an implementation problem. >Because of this, I am almost unable to use const >enum types, and that seems a shame, because it makes me either return >to #define, or actually store things in variables that needn't take up >a storage location. I think you're best off avoiding the alternatives (including your mention of bitfields in your previous message) above and just adding in the extra [agreed, verbose] casts so that you can get on with your work. -- Greg, Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418 Producers of CC C++, SysAdm columnist for UNIX Today!, Microsoft Systems Journal (C programming), + others. Also, BIX c.language & c.plus.plus conf. moderator. Here:attmail!csanta!greg / BIX:comeau / CIS:72331, 3421 / voice:718-849-2355