Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Apr 1996 09:36:13 +0930 (CST)
From:      Michael Smith <msmith@atrad.adelaide.edu.au>
To:        dwhite@resnet.uoregon.edu
Cc:        questions@FreeBSD.ORG
Subject:   Re: How do you declare an enum ?
Message-ID:  <199604040006.JAA22021@genesis.atrad.adelaide.edu.au>
In-Reply-To: <Pine.BSF.3.91.960403092059.1411A-100000@riley-net170-164.uoregon.edu> from "Doug White" at Apr 3, 96 09:23:18 am

next in thread | previous in thread | raw e-mail | index | archive | help
Doug White stands accused of saying:
> 
> What is the gcc way of declaring an enum?

Same as normal C.

> I have a line like this in a .h file:
> 
> enum boolean {false, true};
> 
> When I try to compile this, gcc (and g++) barfs on it, saying that there 
> is a parse error before 'false'.  
> Is there a different way to declare an enum type?

Compiles fine here.  I suspect that you've got another 'true', 'false' or 
'boolean' in scope.

If you're trying to define a boolean type, you want :

typedef enum {false, true} bool_t;

If you just want two constants, one false, the other true, use

#define FALSE	(0)
#define TRUE	(!FALSE)

> Doug White                              | University of Oregon  

-- 
]] Mike Smith, Software Engineer        msmith@atrad.adelaide.edu.au    [[
]] Genesis Software                     genesis@atrad.adelaide.edu.au   [[
]] High-speed data acquisition and      (GSM mobile) 0411-222-496       [[
]] realtime instrument control          (ph/fax)  +61-8-267-3039        [[
]] Collector of old Unix hardware.      "Where are your PEZ?" The Tick  [[



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604040006.JAA22021>