Mail Archives: djgpp/1996/04/16/19:41:33
Reply to message 4333527 from KUKU AT GILBERTO on 04/16/96 9:12AM
>false and true are reserved words in C++. (I'm just stating that without
>knowing it definitely :-)
>
>Change that to
>
>enum Boolean {farse,tlue}; and it will work :-)
In my programs I simply define FALSE and TRUE in uppercase. That
avoids any trouble with predefined constants. Also makes programs
easier to read, IMHO. I've never had any reason to use enums, though -
I just do this:
typedef unsigned char bool;
#if !defined(TRUE)
#define TRUE 1
#endif
#if !defined(FALSE)
#define FALSE 0
#endif
This might still run into the same problems in C++ with 'bool', but why, if
this already has been provided by the language, should one not use it?!
Why bother creating your own types when they already exist?
Just as an aside, to programmers in general: It is really sloppy to write
C code and save it with a C++ extension. It's like writing Fortran and
saving it as a .p file. C and C++ are distinct languages, and though
most C++ compilers will recognize C code and leave it be, you are
bound to run into something like the above eventually.
John
- Raw text -