C++ use of bool

Tony van der Hoff OSLib at mk-net.demon.co.uk
Wed May 17 14:39:39 BST 2000


On Fri, 5 May 2000, at 16:06:10, David Bryan <D.J.Bryan at cranfield.ac.uk>
wrote on the subject "C++ use of bool":

>In message <sKii6NAb9oE5EwYI at mk-net.demon.co.uk>
>          Tony van der Hoff <OSLib at mk-net.demon.co.uk> wrote:
>
>> On Thu, 4 May 2000, at 17:50:51, David Bryan <D.J.Bryan at cranfield.ac.uk>
>> wrote on the subject "C++ use of bool":
>> 
>
>As it turns out, g++ hasn't always had |bool| as a keyword.  

My fledgling types.h now contains this:

--------------------------------------------------------

/* C99 defines bool as a keyword */
#if !defined BOOL_DEFINED && defined ( __STDC_VERSION__ )
  #if __STDC_VERSION__ >= 199901L
    #define BOOL_DEFINED
  #endif
#endif

/* GNU C++ defines bool as a keyword at V2.7 */
#if !defined BOOL_DEFINED && defined __GNUG__
  #if __GNUG__ > 2 || ( __GNUG__ == 2 && __GNUG_MINOR__ >= 7 )
    #define BOOL_DEFINED
  #endif
#endif

/* C++ (1998) defines bool as a keyword, 
** but many implementations included it earlier 
*/
#if !defined( BOOL_DEFINED ) && defined __cplusplus 
  /* CFront defines |__cplusplus| but not |bool| */
  if !defined __CC_NORCROFT
    #define BOOL_DEFINED
  #endif
#endif

#if !defined( BOOL_DEFINED )
   typedef osbool bool;
#endif

--------------------------------------------------------

Does anyone want to comment/criticise? Are there any other little twists
that I ought to know about before committing to this?


-- 
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