Mail Archives: djgpp/1997/01/20/23:45:54
I'm new to djgpp and fairly new to C++ and have run into what seems to
me to be an odd compilation problem.
I'm trying to learn the language from Stanley Lippman's C++ PRIMER, 2nd
edition, and have downloaded Lippman's examples from his FTP site. I
have discovered, when compiling his examples, that djgpp chokes on the
following construction:
enum Boolean {false = 0, true};
For example, consider the following test program:
#include <iostream.h>
main()
{
enum Boolean { false = 0, true };
if (false)
{
cout << "Something is seriously wrong here!\n";
}
else // if !false
{
cout << "This is what you ought to see.\n";
}
return 0;
}
When I compile this with djgpp, the following happens:
C:\USR\ABOSTICK\CXX>gxx -o test.exe test.cc
test.cc: In function `int main()':
test.cc:5: parse error before `false'
C:\USR\ABOSTICK\CXX>
I'm running djgpp version 2, calling v2.7.2.1 of GCC.
When I compile the same program with GCC version 2.5.8 under SunOS
at one of my ISP's machines, it compiles smoothly and executes without
problems.
I've also found that if I change line 5 of my test program to read
enum Boolean { False = 0, True };
djgpp compiles it without problems.
Plainly djgpp is ascribing special meaning to the token 'false' (and
probably 'true' as well). Is it supposed to be doing so?
I notice from some other minor compilation errors when compiling Lippman's
example code that my version of djgpp uses a later evolution of the ANSI
C++ standard than his text does. I infer from this that it is possible
that my problem is also due to evolving standards.
Is that what's going on? That is, does v2.7.2.1 of GCC use a later
definition of C++ than v2.5.8, one in which 'false' and 'true' are
reserved words or something similar?
Or is something else going on? If so, what?
--
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 -