C/C++ and sizes of types
Friday, October 26th, 2007Every so often, I get asked questions along the lines of one of these:
Question type #1:
I need a type that is exactly n bytes/bits long. How do I get this?
Question type #2:
On machine x, the size of some type(usually wchar_t) is wrong! How do I fix it?
I actually just got the second question, hence the reason for this post (although that guy won’t see the answer, because he was a dick). The short answer is this:
(Most) types in C and C++ are either only relatively sized or implementation defined.
