Download

Why does UE4 use uint32 to represent a bool?

Why does UE4 use uint32 to represent a bool? What’s the advantage of using uint32 vs bool?

i think you’ll find they use bitfields alot and the uint32 is used in the bitfield to ensure alignment boundries. it helps make the memory faster to access because its aligned. http://msdn.microsoft.com/en-us/library/ewwyfdbe.aspx

I made a post on SO http://stackoverflow.com/questions/26470095/why-should-i-use-1bit-bitfields-instead-of-bools

You should not add unreal code (this is engine code and not your sample code) to a public forum, you might violate the license agreement.

Now to the questio ^^. Using a bit field saves you a lot of runtime memory, the same can be achieved using a union like: http://www.rightcorner.com/code/CPP/Basic/union/sample.php

IANAL, but I believe you are allowed to post up to 30 lines.

and network bandwidth.

It doesn’t, it just affects how they’re stored. How you pack them in your bit stream is unrelated, you could pack a boolean (8-bit) as 1-bit on the network stream.

Ah thats nice :smiley: Good to know when posting samples :smiley: