delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/17/09:50:25

Date: Wed, 17 Apr 1996 09:37:13 +0200 (MET DST)
From: "Christoph P. Kukulies" <kuku AT gilberto DOT physik DOT rwth-aachen DOT de>
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 <kuku AT gilberto DOT physik DOT rwth-aachen DOT de>
Message-id: <199604170737.JAA06152@gilberto.physik.rwth-aachen.de>
MIME-version: 1.0

> 
> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019