On Tue 2008-05-27 16:38:52 UTC-0000, odbapsvm ([EMAIL PROTECTED]) wrote: > Can someone tell me what controls the size of an int in C language? Is > it the machine architecture, (which pentium chip) I'm using, or is it > the compiler, or does the memory model I'm using have something to do > with it. I think it may be the compiler. Case in point I have an old > pentium III thinkpad. When I run an old MS quickC compiler, I only get > two byte ints, but when I run MS 2008 C++ compiler I get four byte > ints. Is there a way I can tweak the QuickC compiler to use four byte > ints?
sizeof(int) is determined at compile-time, not at run-time. The compiler determines the size of all the data types. From memory the first version of Microsoft Visual C++ provide 16-bit ints for compatibility with code written for Windows 3.0. MSVC 2.0 and newer versions all provide 32-bit ints. sizeof(int) in QuickC is fixed at 2 bytes - you can't change that. Even if you could change it, you'd need a compelling reason to use QuickC for anything serious in 2008. Memory models can change the size of pointers, but shouldn't have any effect on the other fundamental data types.
