This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Definition of 'bool'
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
basetype.h:
#ifdef __cplusplus
#define cyg_halbool bool
#else
#define cyg_halbool char
#endif
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