[ECOS] Definition of 'bool'

Lars Viklund lars.viklund@axis.com
Fri Sep 17 08:39:00 GMT 2004

On Fri, 2004-09-17 at 01:07, Matt Jerdonek wrote:
> We recently added some C++ code and encountered a problem with the definition of 'bool'.  In
> infra/include/cyg_type.h, bool is typedef'd as an int, while in C++ a bool is an 8-bit value.

The size of a C++ bool depends on the ABI. It may be one byte or it may
be the same size as an int.

>   This
> difference causes us problems as when sharing a boolean between C and C++ code because the variable
> is accessed differently.
> I'm wondering if anyone else has seen this problem and how they got around it.  Also, does it make
> sense to change the definition of bool in cyg_type.h to be an 8-bit value?

If the size of a C++ bool is not the same as the size of an int (the
default in infra/current/include/cyg_type.h) the HAL should #define
cyg_halbool to an appropriate type.

For the Axis CRIS (where sizeof(bool) == 1) we do the following in

#ifdef __cplusplus
#define cyg_halbool bool
#define cyg_halbool char

You don't mention which platform you are using, but it sounds like your
HAL should do the same thing.

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list