www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/16/19:41:33

From: j DOT aldrich6 AT genie DOT com
Message-Id: <199604162321.AA169396908@relay1.geis.com>
Date: Tue, 16 Apr 96 23:21:00 UTC 0000
To: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re: Enum Definitions

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 -


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