PDA

View Full Version : The type for XAboolean



rajv
05-19-2008, 05:49 AM
In OpenMaxAL.h the typedef for XAboolean is given as XAint32 which is a 32-bit signed number. But standard C says that the Boolean type is unsigned and has the lowest ranking in its category of standard unsigned integer types. In simple assignments, if the left operand is a Boolean type, then the right operand must be either an arithmetic type or a pointer. An object declared as a Boolean type uses 1 byte of storage space, which is large enough to hold the values 0 or 1.
Why we should have 32-bits allocated for a boolean type? Also to store 0 or 1 shouldn't that be unsigned ?

stuchao
05-29-2008, 08:12 AM
Thank you for the feedback. The header declaration as XAint32 is typographical error. It should be XAuint8. The headers will be corrected.

rajv
06-17-2008, 11:58 PM
I guess if it is made as 8-bit now , holes will be created in many of the structures. This will be a problem especially when we have not used sizeof() operator (eg:- due MISRA-C Rules) in our codes and we have codes where the size of structure is manually calculated.
So it will be better to leave it as 32-bit but as unsigned (XAuint32)