This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Boolean typedefs


I have noticed some weird behaviour recently when using booleans, and
having dug around a bit further would like to see if anyone can
clarify.  There seems to be two different versions of the bool
variable type, depending which order of file inclusions you have.
GCCs stdbool.h typdefs bool to _Bool, whereas eCos provides
cyg_types.h which ultimately typedefs bool to int.  Since I have code
that I'd like to build on multiple platforms, I'd like to be able to
use stdbool.h, which precludes relying solely on the eCos version.
I'd like both to end up at the same definition.

I've tried modifying cyg_types.h to use _Bool instead of int.  I had
to correct a couple of prototype/implementation clashes along the way
(cyg_drv_cond_wait, cyg_semaphore_trywait and
xyzModem_stream_terminate).  I also had to change cyg_bool_t, since it
was always being typedef to int, rather than something more obvious
like cyg_bool.

My code all seems to be working now, and all the various
cyg_bool/cyg_bool_t/bool flavours ultimately end up as _Bool, no
matter where they are picked up from.  I can clean this up and submit
it as a patch, but I'd like to ask if there's a reason (other than the
purely historical) for the use of int in the first place?  Is there
some portability issue that I've missed here?  What's the different
between cyg_halbool, cyg_bool and cyg_bool_t - is this to do with
levels of abstraction?

Thanks in advance

Alan Bowman

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]