"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
sid <ki***********@gmail.comwrites:
>On Jul 2, 10:13 pm, raf...@op.pl wrote:
>>What is the size of int on 64-bit computers ?
size of int is 4 bytes on my AMD athlon 64 bit machine
sizeof(int) could easily be 8 on the same machine with a different
compiler or operating system, or even with different options to the
same compiler.
See the other responses in this thread for a detailed explanation.
'could be', yes, but 'is', probably not.
that is why I, personally, find this thread annoying.
now, on x86-64, will anyone make sizeof(int)==8?...
I would doubt it.
64-bit operations are more expensive than 32 bit ones (at least in terms of
more often requiring a REX prefix, ...).
now, on a different arch? maybe, but also likely not.
and, if a compiler writer did do this?
well, then, a good deal of existing apps would break.
usually, when targeting a particular arch, we make a few assumptions, such
as the sizes of various types, ...
and, people will not change these, lest they risk the resultant crap storm.
and what of 'sizeof(int)==2'? well, those targeting something like dos will
tend to know at least this much. "oh wow, I am targetting dos, I feel like
malloc'ing a 1MB buffer", errm, no...
the compiler has the right and moral obligation to ram its foot up the dev's
backend...
after all, all this is part of why we 'port' apps.
a good deal of apps, regularly make certain assumptions, regardless of
whatever the spec may happen to say.
now, if we were talking about sizeof(long), well then, this one does vary in
this case...
theory is one thing, practice is another...
--
Keith Thompson (The_Other_Keith) ks***@mib.org
<http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*>
<http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"