![]() |
int size is compiler dependent or OS dependent
int size is compiler dependent or OS dependent please do not answer in yes or no,some additional details regarding this will be helpful to me.
|
It depends on the platform (which includes processor, OS, compiler, compiler-options, etc). Ask more specific questions, you will get more specific answers.
|
Quote:
size of int depends on the compiler, but compiler may theoretically change it based on target platform, CPU or compiler switches. |
Yeah, it's a bit of both - on the one hand, the compiler mandates it because it affects the instructions it generates, but on the other hand a standards-compliant compiler is supposed to choose the "most natural" size for the architecture. In practice, it doesn't matter so long as you don't make any assumptions about its size (i.e. use sizeof(int) for moving/storing int values and the intX_t/uintX_t typedefs in stdint.h when you need fixed-size integral values).
|
The real problem imo is why this is an issue to you. You should have typedefs for u16, u32, i32 and so on and you should (almost) never see an int in your code, even less monsters like DWORD, QWORD and the likes o.O
If your language is c++ I can give you a solution for that problem that doesn't even use #ifdefs. |
| All times are GMT -5. The time now is 07:51 PM. |