 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Domel Guest
|
Posted: Sat Jul 22, 2006 8:24 am Post subject: sizeof(int) - processor's architecture depandance |
|
|
Hello
Is value returned by sizeof(int) dependent on processor's
architecture?,
or it is architecture independent and it doesn't matter whether you call
that instruction on 16-bit or 32bit processor - the returned value i
always
the same??.
Any link with relevant explaination or example is warmly welcomed.
Thx
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
speedplane Guest
|
Posted: Sat Jul 22, 2006 11:11 pm Post subject: Re: sizeof(int) - processor's architecture depandance |
|
|
It is most certainly architecture specific. However having a 16-bit,
32-bit, or 64-bit processor does not really make a difference. It
sizeof(int) may still be 4 on a 16-bit processor. On most processors
(except for some really old ones) sizeof(int) will be 4.
However if you think that it will be a problem for you, many people
create a header file and define there own types with fixed sizes....
for example:
typedef unsigned int uint32
typedef signed int int32
typedef signed short int16
....
Then if you try to run your code on some strange architecture you only
need to change the header file.
Domel wrote:
| Quote: | Hello
Is value returned by sizeof(int) dependent on processor's
architecture?,
or it is architecture independent and it doesn't matter whether you call
that instruction on 16-bit or 32bit processor - the returned value i
always
the same??.
Any link with relevant explaination or example is warmly welcomed.
Thx
|
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
James Kanze Guest
|
Posted: Sat Jul 22, 2006 11:24 pm Post subject: Re: sizeof(int) - processor's architecture depandance |
|
|
Domel wrote:
| Quote: | Is value returned by sizeof(int) dependent on processor's
architecture?,
|
Of course. I'm aware of systems where it is 1, 2, 4 or 6;
other values are also possible.
| Quote: | Any link with relevant explaination or example is warmly
welcomed.
|
What's to explain? The standard says that it is implementation
defined, and in practice, it does vary widely.
--
James Kanze kanze.james (AT) neuf (DOT) fr
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|