To my understanding the representation of size_t and wchar_t are completely platform/compiler specific. For instance I have read that wchar_t on Linux is now usually 32bit, but on Windows it is 16bit. Is there any way that I can standardize these to a set size (int, long, etc.) in my own code, while still maintaining backwards comparability with the existing standard C libraries and functions on both platforms?
My goal is essentially to do something like typedef them so they are a set size. Is this possible without breaking something? Should I do this? Is there a better way?
UPDATE: The reason I'd like to do this is so that my string encoding is consistent across both Windows and Linux
Thanks!
Sounds like you're looking for C99's & C++0x's <stdint.h>
/<cstdint>
headers. This defines types like uint8_t
, and int64_t
.
You can use Boost's cstdint.hpp
in the case you don't have those headers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With