Size of D bool vs size of C++ bool

Jeremy DeHaan via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 5 09:54:13 PDT 2017


On Friday, 4 August 2017 at 20:38:16 UTC, Steven Schveighoffer 
wrote:
> On 8/4/17 4:16 PM, Jeremy DeHaan wrote:
>> I'm trying to do some binding code, and I know that C++ bool 
>> isn't defined to be a specific size like D's bool. That said, 
>> can I assume that the two are the same size on the most 
>> platforms?
>
> I shudder to think that D may work with a platform that doesn't 
> consider it to be 1 byte :)
>
>> The only platforms I'm really interested in are Windows, 
>> Linux, OSX, iOS, FreeBSD, Android. The only thing that might 
>> throw me off is if there are some things that Linux or FreeBSD 
>> target where this is not the case, but these machines are 
>> probably out of the scope of my project.
>
> I would say any platform that D currently supports, C++ bool is 
> defined to be 1 byte.
>
> The ldc/gdc guys would know better.
>
> -Steve

Thanks, Steve. I was hoping this was the case and it will 
significantly simplify a lot of my binding code.

I'm curious to see what systems don't have a bool size of 1 byte, 
but perhaps I'll put a check in my CMake file and prevent the 
project from building if it isn't.


More information about the Digitalmars-d-learn mailing list