delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/09/14/13:49:36

Date: Wed, 14 Sep 1994 9:23:41 -0400 (EDT)
From: Chris Tate <FIXER AT FAXCSL DOT DCRT DOT NIH DOT GOV>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: named enum?

Chun-Yu Lee <d791013 AT c2 DOT hinet DOT net> writes:

>    Can the named enumeration be implemented in DJGPP? For example, when
> I compile the small program below:
>
>	enum  bool  {false, true};
>	void main () {
>	  bool foo = false;
>	}
>
> the g++ told me:
>	
>	temp.cc:1: parse error before `bool'.

My guess is that GCC is a sufficiently late version that it supports
the use of the 'bool' type, which has been accepted by the ANSI committee
which is deciding the C++ standard.

If this is true, then you have a couple of options.  First, and most
backwards-compatible, you could rename your enum to something like
"Boolean," which is less likely to collide with a standard reserved
word (in fact, I believe all reserved words are lowercase-only).  This
approach will also work under compilers that do not yet support the
'bool' boolean type.

The second approach is to simply declare your boolean variables as
being of type 'bool,' without declaring the enum.  If GCC does indeed
support a builtin boolean type, then this will work just fine.  It
also has the advantage of being really cutting-edge progressive.  :-)

__________
Christopher Tate                                   fixer AT faxcsl DOT dcrt DOT nih DOT gov
GM/CS$ d(--) H s:- g+ p0 au a- w+ v+(-*) C++ U+(--) E++ N++ K W---(++)$ M++$
   V+ -po+ Y+ t+ 5-- j+ G? tv b+++ D+++ e++ u++(---) h--- f r+++ n+ y+++

- Raw text -


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