Suggestions

Jonathan Coxhead jonathan at doves.demon.co.uk
Tue Apr 25 07:14:41 BST 2000


 | May I strongly suggest *not* to do this unless you can garantee 
that
 | sizeof(bool) [C99] == sizeof(int) [pre C99].

   Ouch! 

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

   Indeed. Good point.

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

   Ick! 

   The other way to avoid trouble is to avoid compilers that have the 
problem. Obviously, M$ isn't a problem for us. If Norcroft C99 
(if/when it appears) and GNU C/C++ both have |sizeof (bool) == 4| 
then we have no issue.

   If they have some other setting, we still have no issue with C---
just don't include <stdbool.h> in C99, but do what we do now.

   But C++ would be a problem ... |bool, true, false| are keywords. I 
suppose in that case, we'd have to blow the backwards compatibility, 
and use |osbool, ostrue, osfalse|. Either that, or see if we can use 
the native type (by adding it to the "ByteWide" type list, and having 
separate libraries for C and C++). "Ick!" again, but that might be 
best.

 | Or still
 | sticking to the current situation and hoping the standard commitee
 | will never assign a new meaning to 'TRUE' & 'FALSE'...

   This is my preference.

        /|
 o o o (_|/
        /|
       (_/



More information about the oslib-user mailing list