Date: Wed, 17 Apr 1996 09:37:13 +0200 (MET DST) From: "Christoph P. Kukulies" Subject: Re: Enum Definitions In-reply-to: <199604162321.AA169396908@relay1.geis.com> from <"j DOT aldrich6 AT genie DOT com"@Apr> To: j DOT aldrich6 AT genie DOT com Cc: djgpp AT delorie DOT com Reply-to: Christoph Kukulies Message-id: <199604170737.JAA06152@gilberto.physik.rwth-aachen.de> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit > > 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