bool (again?)

Tony van der Hoff tony at mk-net.demon.co.uk
Thu May 2 19:49:47 BST 2002


On 2 May 2002, in message <d1bd63304b.kbracey at kbracey.cam.pace.co.uk>,
Kevin Bracey <kevin.bracey at pace.co.uk> wrote:

> I've been busy upgrading Norcroft to C99, and I'd like to make a minor
> suggestion for the next version of OSLib. As well as checking for
> __STDC_VERSION__, could you also make it check for
> __bool_true_false_are_defined?
> 
> It'll be some time before Norcroft makes it to the point where I could set
> __STDC_VERSION__ to 1999xx with a straight face, but in the interim,
> checking for __bool_true_false_are_defined will catch the intermediate
> versions, as long as people #include <stdbool.h> before any OSLib headers.
> 

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. 

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

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?

-- 
Tony van der Hoff         | MailTo:tony at mk-net.demon.co.uk
                          | MailTo:avanderhoff at iee.org
Buckinghamshire, England  | http:www.mk-net.demon.co.uk



More information about the oslib-user mailing list