C++ use of bool

David Bryan D.J.Bryan at cranfield.ac.uk
Fri May 5 21:02:55 BST 2000


In message <Marcel-1.53-0505171304-bc86#xE at druck.freeuk.com>
          "David J. Ruck" <druck at freeuk.com> wrote:

> On Fri 05 May, Tony van der Hoff wrote:
> [#ifdef logic for determining bool keyword]
> > If anyone has any better suggestions, I'd be pleased to hear them.
> 
> There is a way which avoids having know all the compiler versions, but is
> somewhat nasty, and probably not suitable for the user base of OSLib.
> 
> When installing the library to automatically generate a header file using a
> script and a small piece of code which is compiled by the target compiler.

What if I use both cc and g++?  I will need two versions of
types.h.  What would be a good way to ensure the correct one was
found for each compiler?

> I've used this technique myself with multi-platform programs that need
> to know the endianness of the processor and structure packing attributes
> of the compiler. When porting to a new platform you run a small program
> which generates a few #defines's which are then added to a header file
> in a #ifdef block for that platform & compiler (which prevents an #error
> being reached for unknown platforms).

Tony was trying to make the detection of the compiler automatic. 
The correct #ifdef block would have to be triggered by the user,
otherwise it seems a bit circular.

-- 
David Bryan




More information about the oslib-user mailing list