Mail Archives: djgpp/1997/01/23/00:47:31
Robert Hoehne <Robert DOT Hoehne AT Mathematik DOT tu-chemnitz DOT de> writes:
>Alan Bostick wrote:
>>
>> have discovered, when compiling his examples, that djgpp chokes on the
>> following construction:
>> enum Boolean {false = 0, true};
>It is not DJGPP but gcc which complains the above. The reason: 'false'
>and
>'true' are reserved words in gcc of the new type 'bool'. If you realy
>want
>to declare your own Boolean type, use any other (not reserved) words.
>But I
>think the better way is to use the 'bool' type, because it is stored as
>a single byte but an 'enum' is stored (mostly) as an int (4 bytes).
It's not that I *want* to declare my own Boolean type; it's just that
the sample code that goes with Stanley Lippman's otherwise excellent
C++ PRIMER declares that type all over the place. It's a bit of a hassle,
don't you know, to have to re-edit the sources to ensure compliance with
the new language definition.
As I mentioned, the code compiled just fine under GCC v2.5.8 under SunOS;
it only bombed under v2.7.2.1 .
There are other places where Lippman uses obsolete constructions. For
example, he frequently uses an old scoping for for-loop variables:
for (int ix=0; ix < size; ix++)
{
/* blah blah blah */
}
for (ix=0; ix < size; ix++)
{
/* etc. etc. etc. */
}
GCC v2.7.2.1 thinks the scope of ix applies only within the first loop's
statement block, issuing a warning about using an obsolete scoping. Either
ix should be declared outside both loops, or redeclared in the second one,
in direct contradiction to Lippman's discussion of for-loop scoping on
p.141 of the 2nd edition.
Reminder: *I am not calling this a bug in GNU CC or djgpp!* I'm only
observing how the evolution of the definition of C++ makes writing a textbook
a job of trying to hit a moving target. People trying to learn the language
sometimes have to do some detective work to discover why their textbook-legal
code won't compile or behaves peculiarly. (So nu -- I still use the original,
pre-ANSI edition of Kerhighan and Ritchie. ;-) )
--
Alan Bostick | To achieve harmony in bad taste is the height
mailto:abostick AT netcom DOT com | of elegance.
news:alt.grelb | Jean Genet
http://www.alumni.caltech.edu/~abostick
- Raw text -