C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

sizeof(int) - processor's architecture depandance

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Domel
Guest





PostPosted: Sat Jul 22, 2006 8:24 am    Post subject: sizeof(int) - processor's architecture depandance Reply with 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
speedplane
Guest





PostPosted: Sat Jul 22, 2006 11:11 pm    Post subject: Re: sizeof(int) - processor's architecture depandance Reply with quote



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





PostPosted: Sat Jul 22, 2006 11:24 pm    Post subject: Re: sizeof(int) - processor's architecture depandance Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.