I've been told that i should use size_t
always when i want 32bit unsigned int
, i dont quite understand why, but i think it has something to do with that if someone compiles the program on 16 or 64 bit machines, the unsigned int
would become 16 or 64 bit but size_t
wont, but why doesnt it? and how can i force the bit sizes to exactly what i want?
So, where is the list of which datatype to use and when? for example, is there a size_t
alternative to unsigned short
? or for 32bit int
? etc. How can i be sure my datatypes have as many bits as i chose at the first place and not need to worry about different bit sizes on other machines?
Mostly i care more about the memory used rather than the marginal speed boost i get from doubling the memory usage, since i have not much RAM. So i want to stop worrying will everything break apart if my program is compiled on a machine thats not 32bit. For now ive used size_t
always when i want it to be 32bit, but for short
i dont know what to do. Someone help me to clear my head.
On the other hand: If i need 64 bit size variable, can i use it on a 32bit machine successfully? and what is that datatype name (if i want it to be 64bit always) ?