bool (again?)

Kevin Bracey kevin.bracey at pace.co.uk
Fri May 3 12:47:28 BST 2002


In message <976f73304b.Tony at mk-net.demon.co.uk>
          Tony van der Hoff <tony at mk-net.demon.co.uk> wrote:

> Yes, that should be OK, but the logic round there is getting a bit hairy
> for my simple mind ;-)
> 
> Can you clarify whether __bool_true_false_are_defined has formally entered
> the language; I was unable to find it in my draft C99, so I assume not. 

It is defined when <stdbool.h> is included. It might not have been in the
draft.

> Presumably Norcroft can't define __STDC_VERSION__ for any value at all?

Well, it could define it for ISO C90, probably, if there was a corresponding
value. I've only got the ANSI C89 standard, and the C99 ISO standard,
unfortunately. It's some way off full C99 at the moment, but mainly in the
library. Most of the language is basically working.

> So, something like this seems appropriate:
> 
> #if !defined BOOL_DEFINED
>   /* C99 defines bool as a keyword */ 
>   #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
>     #define BOOL_DEFINED
>   #endif
>   
>   /* <stdbool.h> defines bool as an enum */
>   #if defined __bool_true_false_are_defined
>     #define BOOL_DEFINED
>   #endif
> #endif  
> 
> Has anyone any objections/improvements to that?

That'll give you a duplicate definition warning, for full C99 compilers where
<stdbool.h> has been included.

-- 
Kevin Bracey, Principal Software Engineer
Pace Micro Technology plc                     Tel: +44 (0) 1223 518566
645 Newmarket Road                            Fax: +44 (0) 1223 518526
Cambridge, CB5 8PB, United Kingdom            WWW: http://www.pace.co.uk/



More information about the oslib-user mailing list