delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/01/28/21:13:29

Date: Sat, 28 Jan 95 12:16 PST
From: jdp AT polstra DOT com (John Polstra)
To: djgpp AT polstra DOT com
Subject: Re: 'enum' problem (kind of) solved

> I was having problems with an enum data type, as such:
> 
> enum boolean {false, true};
> 
> and GCC reported a parse error before false.

Be advised, "false" and "true" are keywords in C++.  They're a recent
addition, and most vendors haven't implemented them yet -- but GCC has.
If your program is written in C++, or if the compiler *thinks* it is,
then you'll get exactly the error you reported.  If your program is
really a C program (not C++), you can add "-x c" to the compiler command
line, to make sure that the compiler treats it as a C program regardless
of its filename suffix.  If it's a C++ program, though, you are going to
have to change the program to solve this problem.

Incidentally, "bool" is also a keyword in C++ now.  These are not GNU
extensions; they are mandated by the emerging ANSI/ISO C++ standard.

   John Polstra                                       jdp AT polstra DOT com
   John D. Polstra & Co., Inc.                Seattle, Washington USA
   "Self-knowledge is always bad news."                 -- John Barth

- Raw text -


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