Suggestions
John Tytgat
John.Tytgat at aaug.net
Mon Apr 24 23:47:04 BST 2000
In message <200004242010.NAA17446 at purple.trimedia.sv.sc.philips.com>
"Jonathan Coxhead" <jonathan at doves.demon.co.uk> wrote:
> #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
> #include <stdbool.h>
> #define TRUE true
> #define FALSE false
> #else
> typedef int bool;
> #ifndef FALSE
> #define FALSE ((bool) 0)
> #endif
> #ifndef TRUE
> #define TRUE ((bool) 1)
> #endif
> #endif
May I strongly suggest *not* to do this unless you can garantee that
sizeof(bool) [C99] == sizeof(int) [pre C99].
The M$ C++ compiler can certainly not be used as a reference but its
sizeof(bool) is 1 which means that including C headers and their
corresponding library into a C++ project breaks miserably when those
headers are using bool in e.g. structs with a definition as outlined
above.
Been there, done that and didn't like it at all. :-(
The only way to avoid troubles is to use something 'unique' as
'osbool' with corresponding 'ostrue' and 'osfalse'. Or still
sticking to the current situation and hoping the standard commitee
will never assign a new meaning to 'TRUE' & 'FALSE'...
John.
--
John Tytgat, in his comfy chair at home Question 210:
John.Tytgat at aaug.net Why do "fat chance" and "slim chance"
BASS mean the same thing ?
More information about the oslib-user
mailing list