The answers around the web (one, two) only tell parts of the story, and omit some details that I would love you to help me to clarify:
- int, by the C++ standard, must be >= 32 bits.
- Different compilers (implementations) can make
int
to allocate different amount of bits by default. SoCompiler A
can makeint
to allocate 50 bits (for example) when I declare integer. - Also, different compilers may / may not use bit padding for optimization
__int32
(Microsoft-specifc) andint32_t
are here to solve the problem and:- Force compiler to allocate exactly 32 bits.
- Never use bit padding before / after this data type.
Which one of my guesses are correct? Sorry to reasking old question, but I am actally confused in all of that allocation features.
Thanks in advance for your time.