I need a cross-architecture way to ensure that a float will be 4 bytes (as is on 32-bit windows). For instance, in the structs I’m creating, I’m using __int32 instead of int to ensure an integer value that is 4 bytes long.
How could I do this with a float? I know that I can just substitute the value with an __int32 type; however, when casting to a float on 64-bit systems, won’t I have issues?
There is no analog to
int32_tfor floating-point values.The only cross-platform way to achieve what you want is to test for it with either runtime or static asserts.