Mail Archives: djgpp/1996/04/17/09:50:25
>
> 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:
I didn't want to suggest sincerely using farse,tlue as variables
in the program (that's why I used a smiley). When we are at judging
about style I would state that defining a pair of boolean variables
as an enum is bad style anyway since I'm not sure where is guaranteed
that the compiler always chooses the value 0 for the first
entry in the enum list - maybe it's defined in ANSI somewhere.
At least I would consider it dangerous.
>
> 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
>
--Chris Christoph P. U. Kukulies kuku AT gil DOT physik DOT rwth-aachen DOT de
- Raw text -