Thread: RE: [GD-General] meaning of sizeof(int) on all plateform
Brought to you by:
vexxed72
From: Gareth L. <GL...@cl...> - 2003-06-26 18:42:24
|
sizeof(int) =3D size of integer value. As defined by the compiler = vendor. There is no "Correct" way to set the size of int. -----Original Message----- From: Lagarde S=E9bastien [mailto:Lag...@wa...] Sent: 26 June 2003 19:36 To: gam...@li... Subject: [GD-General] meaning of sizeof(int) on all plateform Hello all,=20 I have some problem to define what represent sizeof(int). =20 IMO sizeof(int) =3D=3D memory bus address width =20 but on platforme like PS2, you have a bus of 128 and sizeof(int) =3D=3D = 32. =20 i have seen elsewherre that sizeof(int) =3D=3D size of a register. =20 Is someone have some information on this point ? thanks ------------------------------- Lagarde S=E9bastien Neko entertainment Junior programmer =20 |
From: Mat N. \(BUNGIE\) <mat...@mi...> - 2003-06-26 21:47:58
|
Those relationships aren't guaranteed in the standard. MSN -----Original Message----- From: gam...@li... [mailto:gam...@li...] On Behalf Of mitea Sent: Thursday, June 26, 2003 2:38 PM To: gam...@li... Subject: RE: [GD-General] meaning of sizeof(int) on all plateform sizeof(int)=3Dsizeof(void*)=3Dsizeof(pointer) sizeof(short)=3Dsizeof(WORD)=3D2 sizeof(long)=3Dsizeof(DWORD)=3D4 sizeof(__int64)=3Dsizeof(LARGE_INTEGER)=3D8 sizeof(char)=3Dsizeof(BYTE)=3D1 |
From: Jones, C. <CJ...@bl...> - 2003-06-26 22:20:26
|
This is all the standard has to say on the size of ints: "There are four signed integer types: "signed char", "short int", "int", and "long int." In this list, each type provides at least as much storage as those preceding it in the list. Plain ints have the natural size suggested by the architecture of the execution environment (1); the other signed integer types are provided to meet special needs." "(1) that is, large enough to contain any value in the range of INT_MIN and INT_MAX, as defined in the header <climits>." In other words, the result of sizeof(int) is never guaranteed to be of a certain size. Although I believe the ISO C99 standard added new header file, stdint.h, which declares some typedefs for specific sized integer types. If only more compilers would follow the standards... Chris -----Original Message----- From: gam...@li... [mailto:gam...@li...] On Behalf Of mitea Sent: Thursday, June 26, 2003 2:38 PM To: gam...@li... Subject: RE: [GD-General] meaning of sizeof(int) on all plateform sizeof(int)=sizeof(void*)=sizeof(pointer) sizeof(short)=sizeof(WORD)=2 sizeof(long)=sizeof(DWORD)=4 sizeof(__int64)=sizeof(LARGE_INTEGER)=8 sizeof(char)=sizeof(BYTE)=1 ------------------------------------------------------- This SF.Net email is sponsored by: INetU Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php _______________________________________________ Gamedevlists-general mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-general Archives: http://sourceforge.net/mailarchive/forum.php?forum_idU7 |
From: J C L. <cl...@ka...> - 2003-06-30 01:58:23
|
On Thu, 26 Jun 2003 15:12:48 -0700 Chris Jones <Jones> wrote: > This is all the standard has to say on the size of ints: "There are > four signed integer types: "signed char", "short int", "int", and > "long int." In this list, each type provides at least as much storage > as those preceding it in the list. Plain ints have the natural size > suggested by the architecture of the execution environment (1); the > other signed integer types are provided to meet special needs." Precisely. This is why on Crays there's a compilation environment where: sizeof(char) == sizeof(short) == sizeof(int) == sizeof(long) == sizeof(void*) == 1 Note also that ANSI doesn't require bytes to be 8bits. In the above case bytes are 64bits. > In other words, the result of sizeof(int) is never guaranteed to be of > a certain size. Although I believe the ISO C99 standard added new > header file, stdint.h, which declares some typedefs for specific sized > integer types. If only more compilers would follow the standards... Yeah. -- J C Lawrence ---------(*) Satan, oscillate my metallic sonatas. cl...@ka... He lived as a devil, eh? http://www.kanga.nu/~claw/ Evil is a name of a foeman, as I live. |
From: Gareth L. <GL...@cl...> - 2003-06-27 08:59:27
|
This one is more for the archives. The following is wrong. It happens to be right for win32, and maybe for = some other platforms, but is not guarenteed. The only correct thing to assume is long >=3D int >=3D short >=3D char also sizeof (unsigned T) =3D=3D sizeof (signed T)=20 btw, sizeof(pointer) isn't a real value, it is perfectly valid for a = certain platform to have differant sizes of pointers, so sizeof (void*) is not always =3D=3D sizeof(int*). -----Original Message----- From: mitea [mailto:mi...@bb...] Sent: 26 June 2003 22:38 To: gam...@li... Subject: RE: [GD-General] meaning of sizeof(int) on all plateform sizeof(int)=3Dsizeof(void*)=3Dsizeof(pointer) sizeof(short)=3Dsizeof(WORD)=3D2 sizeof(long)=3Dsizeof(DWORD)=3D4 sizeof(__int64)=3Dsizeof(LARGE_INTEGER)=3D8 sizeof(char)=3Dsizeof(BYTE)=3D1 ---------------------------------- Peace and love, Tweety mi...@bb... - twe...@us... YahooID: tweety_04_01 -----Original Message----- From: gam...@li... [mailto:gam...@li...] On Behalf Of Lagarde S=E9bastien Sent: Thursday, June 26, 2003 9:36 PM To: gam...@li... Subject: [GD-General] meaning of sizeof(int) on all plateform Hello all,=20 I have some problem to define what represent sizeof(int). IMO sizeof(int) =3D=3D memory bus address width but on platforme like PS2, you have a bus of 128 and sizeof(int) =3D=3D = 32. i have seen elsewherre that sizeof(int) =3D=3D size of a register. Is someone have some information on this point ? thanks ------------------------------- Lagarde S=E9bastien Neko entertainment Junior programmer |
From: Ivan-Assen I. <as...@ha...> - 2003-06-27 09:31:18
|
> On 64bit windows, int is 64bit=>8 bytes. It's the > size of the memory address. Wrong! MSDN states that on Win64, sizeof(int)==4, sizeof(long)==4 (in the interest of keeping most code working), but sizeof(void *)==8. So code that assumes you can store a pointer in the memory for the int will need to be reworked. Microsoft have made the (IMO correct) assumption that the most important benefit of a 64-bit platform is not integer calculation with 64 bits, but rather, 64-bit addressing. |
From: Daniel V. <vo...@ep...> - 2003-06-27 13:30:24
|
> MSDN states that on Win64, sizeof(int)==4, sizeof(long)==4 > (in the interest of keeping most code working), but > sizeof(void *)==8. So code that assumes you can store > a pointer in the memory for the int will need to be reworked. FWIW, sizeof(long)==8 with gcc on e.g. Hammer. -- Daniel, Epic Games Inc. |
From: <phi...@pl...> - 2003-06-27 16:34:05
|
> FWIW, sizeof(long)==8 with gcc on e.g. Hammer. That's eminently sensible. I seem to remember reading in an issue of the C/C++ Journal that there were new bit-specific type identifiers in one of the upcoming draft standards (possibly the C one) that looked disturbingly like templates. Something like int<64> although probably much more wordy, and introducing a whole new set of very long reserved words. Still, at least it's one of those problems that only rears it's head when you assimilate a new platform, Cheers, Phil |
From: Jay W. <woo...@Ro...> - 2003-06-27 23:52:11
|
Hold on -- it seems to me that the existence of forward declaration necessi= tates that all pointers be the same size. I suppose you wouldn't lose information when casting, as long as it's guara= nteed that sizeof(void*) >=3D sizeof(any other pointer). Still, my underst= anding has always been that all pointers are the same size. =20 > -----Original Message----- > From: Gareth Lewin [mailto:GL...@cl...] > Sent: Friday, June 27, 2003 1:45 AM > To: gam...@li... > Subject: RE: [GD-General] meaning of sizeof(int) on all plateform >=20 >=20 > btw, sizeof(pointer) isn't a real value, it is perfectly=20 > valid for a certain > platform to have differant sizes of pointers, so sizeof (void*) is not > always =3D=3D sizeof(int*). |
From: Evan R. <ev...@en...> - 2003-06-28 02:23:31
|
On Friday, June 27, 2003, at 04:52 PM, Jay Woodward wrote: > Hold on -- it seems to me that the existence of forward declaration > necessitates that all pointers be the same size. > > I suppose you wouldn't lose information when casting, as long as it's > guaranteed that sizeof(void*) >= sizeof(any other pointer). Still, my > understanding has always been that all pointers are the same size. Once again, the segmented architecture of the 8088 under DOS is a counterexample. There are "near pointers" which are 16 bit offsets into a standardized segment, and "far pointers" which are 32 bit segment:offset pairs (which makes comparing far pointers interesting, BTW). I can easily imagine an embedded architecture having different length pointers for code pointers and data pointers, as well. In that case, I assume (always dangerous) that void * would be large enough to hold the largest pointer, as Jay suggests, above. Evan >> -----Original Message----- >> From: Gareth Lewin [mailto:GL...@cl...] >> Sent: Friday, June 27, 2003 1:45 AM >> To: gam...@li... >> Subject: RE: [GD-General] meaning of sizeof(int) on all plateform >> >> >> btw, sizeof(pointer) isn't a real value, it is perfectly >> valid for a certain >> platform to have differant sizes of pointers, so sizeof (void*) is not >> always == sizeof(int*). > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Free pre-built ASP.NET sites including > Data Reports, E-commerce, Portals, and Forums are available now. > Download today and enter to win an XBOX or Visual Studio .NET. > http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/ > 01 > _______________________________________________ > Gamedevlists-general mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_idU7 > > > -- Engines of Mischief Consulting <http://www.enginesofmischief.com> Mischievous Ramblings <http://www.enginesofmischief.com/blogs/ramblings> The Engine of Mischief <http://www.enginesofmischief.com/engine> Mischief's Travelblog <http://www.enginesofmischief.com/blogs/travelblog> Today's Oxymoron: Act naturally |
From: Daniel V. <vo...@ep...> - 2003-06-28 02:46:52
|
> I can easily imagine an embedded architecture having > different length pointers for code pointers and data pointers, > as well. In that case, I assume (always dangerous) that > void * would be large enough to hold the largest pointer, as > Jay suggests, above. Section 3.9.2.4 of the ANSI C++ standard guarantees that a void pointer can hold any object pointer. -- Daniel, Epic Games Inc. |
From: brian s. <pud...@po...> - 2003-06-28 21:13:49
|
It is wrong to assume that all pointers are the same size, even on "normal" architectures. Pointers to class members are not required to be sizeof(void *), and in the case of virtual inheritance, probably aren't. This program: // Compile under VC++ with "cl /ML /GX test.cpp" #include <iostream> using namespace std; struct Base { }; struct Derived : public virtual Base { }; typedef void (Base::*BasePtrToMember)(); typedef void (Derived::*DerivedPtrToMember)(); int main(int argc, char **argv) { cout << "sizeof(BasePtrToMember) " << sizeof(BasePtrToMember) << endl; cout << "sizeof(DerivedPtrToMember) " << sizeof(DerivedPtrToMember) << endl; return 1; } Produces the following output: sizeof(BasePtrToMember) 4 sizeof(DerivedPtrToMember) 12 There you go, a 12 byte pointer on Win32. You can imagine that this causes brain-bending bugs for the unwary :) --brian Jay Woodward wrote: >Hold on -- it seems to me that the existence of forward declaration necessitates that all pointers be the same size. > >I suppose you wouldn't lose information when casting, as long as it's guaranteed that sizeof(void*) >= sizeof(any other pointer). Still, my understanding has always been that all pointers are the same size. > > > > >>-----Original Message----- >>From: Gareth Lewin [mailto:GL...@cl...] >>Sent: Friday, June 27, 2003 1:45 AM >>To: gam...@li... >>Subject: RE: [GD-General] meaning of sizeof(int) on all plateform >> >> >>btw, sizeof(pointer) isn't a real value, it is perfectly >>valid for a certain >>platform to have differant sizes of pointers, so sizeof (void*) is not >>always == sizeof(int*). >> >> |
From: Enno R. <en...@de...> - 2003-06-28 22:49:02
|
Jay Woodward wrote: > Hold on -- it seems to me that the existence of forward declaration necessitates that all pointers be the same size. > > I suppose you wouldn't lose information when casting, as long as it's guaranteed that sizeof(void*) >= sizeof(any other pointer). Still, my understanding has always been that all pointers are the same size. Life would be so nice if we had some guarantees like that. The only thing that I know you have a guarantee for is that void* and char* are compatible, and it's necessary that pointers to structs can be cast between each other. However, on several architectures function pointers will be of a different size than data pointers. On a Cray, if I remember this correctly, both void* and char* are 64 bits, but all other pointers are only represented using 32 bits. And you can choose to have ints represented with only 46 instead of the full 64 bits! Enno. -- <xterm> The problem with America is stupidity. I'm not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself? |
From: J C L. <cl...@ka...> - 2003-06-30 01:58:52
|
On Fri, 27 Jun 2003 16:52:01 -0700 Jay Woodward <woo...@Ro...> wrote: > Hold on -- it seems to me that the existence of forward declaration > necessitates that all pointers be the same size. Nope. ANSI doesn't require it. It merely requires that a void* be able to store a pointer of any other type, and that a void* can be converted to a pointer of any other type without loss (and get the proper address). Now as to how the compiler accomplishes this is of course part of that undefined black magic which is left up to compiler authors. ObNote: I've worked on platforms where different pointer types had different sizes and the compilers handled it just fine. > I suppose you wouldn't lose information when casting, as long as it's > guaranteed that sizeof(void*) >= sizeof(any other pointer). Still, my > understanding has always been that all pointers are the same size. Even that's not required. You're assuming a flat memory model and that pointers are basically integral types. This is not required and is in fact not true on several platforms where pointers are variously complex structures. The real kickers are those systems where: type_foo *ptr1, *ptr2; ...code that messes with ptr1 and ptr2... if (memcmp (ptr1, ptr2, sizeof (ptr1))) { printf ("memcmp comparison failed!\n"); } if (ptr1 == tr2) { printf ("pointer comparison succeeded!\n"); } On some hosts you can get cases where both printf() calls will be executed. -- J C Lawrence ---------(*) Satan, oscillate my metallic sonatas. cl...@ka... He lived as a devil, eh? http://www.kanga.nu/~claw/ Evil is a name of a foeman, as I live. |
From: mitea <mi...@bb...> - 2003-06-28 11:50:15
|
> -----Original Message----- > From: gam...@li... > [mailto:gam...@li...] On > Behalf Of Gareth Lewin > Sent: Friday, June 27, 2003 11:45 AM > To: gam...@li... > Subject: RE: [GD-General] meaning of sizeof(int) on all plateform > > > btw, sizeof(pointer) isn't a real value, it is perfectly > valid for a certain > platform to have differant sizes of pointers, so sizeof (void*) is not > always == sizeof(int*). Say again I state that sizeof(T*) is the same, whatever T might be. Am I wrong? ---------------------------------- Peace and love, Tweety mi...@bb... - twe...@us... YahooID: tweety_04_01 |
From: Daniel V. <vo...@ep...> - 2003-06-28 19:54:43
|
> I state that sizeof(T*) is the same, whatever T might be. Am I wrong? I'm not aware of any implementation where this is not the case though the standard doesn't guarantee it. -- Daniel, Epic Games Inc. |
From: Bo-Staffan L. <bo-...@gb...> - 2003-06-28 20:28:46
|
> I'm not aware of any implementation where this is not the case though > the standard doesn't guarantee it. It depends on the CPU architecture. The smallest addressable unit in the C++ memory model is the byte. The number of bits in a C++ byte is implementation-specific, but to be compatible with C, it must contain atleast 8 bits. Typically, if the size of a built in type is smaller than the smallest addressable unit of the CPU, the CPU-byte, the implementation must include an offset, in conjunction with the CPU-byte address, to be able to address the C++ byte within the CPU-byte. Bo-Staffan |
From: Phil T. <ph...@mi...> - 2003-06-28 21:16:38
|
Actually pointer to member functions throw a wrench into this = discussion, specifically when forward declaring classes. There was a = thread on this in the software engineering list. =20 The example given was this: =20 class C; int (C::*pmf)(); C* p; =20 int n =3D (p->*pmf)(); =20 Note that the full declaration of the class C is not required for this = code to compile; however, the member function could be virtual/multiply = inherited/etc so the pointer has to encode this information. =20 On Win32 some compilers will generate this as a 16 byte pointer; others, = will generate stub code and return a pointer to that code which is then = a 4 byte pointer. VC 7 has some compiler options that let you choose = the behavior. =20 The point being that there are things that look like pointers but that = aren't the same size as other native pointers. =20 Phil =20 ________________________________ From: gam...@li... on behalf of = Daniel Vogel Sent: Sat 28.06.2003 12:54 To: gam...@li... Subject: RE: [GD-General] meaning of sizeof(int) on all plateform > I state that sizeof(T*) is the same, whatever T might be. Am I wrong? I'm not aware of any implementation where this is not the case though the standard doesn't guarantee it. -- Daniel, Epic Games Inc. ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01 _______________________________________________ Gamedevlists-general mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-general Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=3D557 |
From: Mick W. <mi...@ne...> - 2003-06-26 19:39:54
|
128 bits would give you 16 bytes, not 32. =20 On the PS2 an int is generally 32 BITS, (4 bytes), which is maybe where the confusion arose. =20 Mick -----Original Message----- From: gam...@li... [mailto:gam...@li...] On Behalf Of Gareth Lewin Sent: Thursday, June 26, 2003 11:42 AM To: gam...@li... Subject: RE: [GD-General] meaning of sizeof(int) on all plateform sizeof(int) =3D size of integer value. As defined by the compiler = vendor. There is no "Correct" way to set the size of int. -----Original Message----- From: Lagarde S=E9bastien [mailto:Lag...@wa...] Sent: 26 June 2003 19:36 To: gam...@li... Subject: [GD-General] meaning of sizeof(int) on all plateform Hello all,=20 I have some problem to define what represent sizeof(int). =20 IMO sizeof(int) =3D=3D memory bus address width =20 but on platforme like PS2, you have a bus of 128 and sizeof(int) =3D=3D = 32. =20 i have seen elsewherre that sizeof(int) =3D=3D size of a register. =20 Is someone have some information on this point ? thanks ------------------------------- Lagarde S=E9bastien Neko entertainment Junior programmer =20 |
From: <Lag...@wa...> - 2003-06-26 20:14:39
|
Messageno confusion here,=20 Following suestion here are purelly curiosity: i precise the question: if you have a 32 bit architecture (pentium) if you want make fast arithmetic operation, you must work with type which have a size of 32bits. These type have the same size of a register and the arithmetic operation can be optimize... typically, this is type "int" on a 64 bit architecture (itanium)=20 register are 64 bit and int are 64bit too so if you have a program which perform the following code: // imaginary define // the goal of this define is to have s32 on 32bits #ifdef __32Bit__ typedef int s32 #else // __64bit__ typedef short u32 // just for exemple #endif void add(s32 a1, s32 a2) { return a1 + a2; } the performance can be poor on a 64bit architecture because we are not in the native size of the register if we have this code void add(int a1, int a2) { return a1 + a2; } no problem, cause "int" is native to the architecture it is my imagination, I'am in the wrong way ? another question, is sizeof(int) =3D=3D sizeof(void*) ? sizeof(void*) must be : size of memory bus address so sizeof(int).... -------------------------- Lagarde S=E9bsatien Neko entertainment Junior programmer ----- Original Message -----=20 From: Mick West=20 To: gam...@li...=20 Sent: Thursday, June 26, 2003 8:48 PM Subject: RE: [GD-General] meaning of sizeof(int) on all plateform 128 bits would give you 16 bytes, not 32. On the PS2 an int is generally 32 BITS, (4 bytes), which is maybe = where the confusion arose. Mick -----Original Message----- From: gam...@li... = [mailto:gam...@li...] On Behalf Of = Gareth Lewin Sent: Thursday, June 26, 2003 11:42 AM To: gam...@li... Subject: RE: [GD-General] meaning of sizeof(int) on all plateform sizeof(int) =3D size of integer value. As defined by the compiler = vendor. There is no "Correct" way to set the size of int. -----Original Message----- From: Lagarde S=E9bastien [mailto:Lag...@wa...] Sent: 26 June 2003 19:36 To: gam...@li... Subject: [GD-General] meaning of sizeof(int) on all plateform Hello all,=20 I have some problem to define what represent sizeof(int). IMO sizeof(int) =3D=3D memory bus address width but on platforme like PS2, you have a bus of 128 and sizeof(int) = =3D=3D 32. i have seen elsewherre that sizeof(int) =3D=3D size of a register. Is someone have some information on this point ? thanks ------------------------------- Lagarde S=E9bastien Neko entertainment Junior programmer |
From: <phi...@pl...> - 2003-06-26 21:25:00
|
> another question, is sizeof(int) == sizeof(void*) ? No, not guaranteed to be, but often is. Cheers, Phil |
From: Evan R. <ev...@en...> - 2003-06-26 22:25:11
|
From: Evan Robinson <ero...@en...> Date: Thu Jun 26, 2003 2:36:27 PM US/Pacific To: gam...@li... Subject: Re: [GD-General] meaning of sizeof(int) on all plateform On Thursday, June 26, 2003, at 01:12 PM, Lagarde S=E9bastien wrote: > no confusion here, > Following suestion here are purelly curiosity: > =A0 > i precise the question: > =A0 > if you have a 32 bit architecture (pentium) > if you want make fast arithmetic operation, you > must work with type which have a size of 32bits. > These type have the same size of a register and the > arithmetic operation can be optimize... > typically, this is type "int" > =A0 > on a 64 bit architecture (itanium) > register are 64 bit and int are 64bit too > =A0 > so if you have a program which perform the following code: > =A0 > // imaginary define > // the goal of this define is to have s32 on 32bits > #ifdef __32Bit__ > typedef int s32 > #else // __64bit__ > typedef short u32=A0 // just for exemple > #endif > =A0 > void add(s32 a1, s32 a2) > { > =A0=A0=A0 return a1 + a2; > } > =A0 > the performance can be poor on a 64bit architecture because we are not > in the native size of the register > =A0 > if we have this code > =A0 > void add(int a1,=A0int a2) > { > =A0=A0=A0 return a1 + a2; > } > =A0 > no problem, cause "int" is native to the architecture Not necessarily. "int" is a logical construct *of the compiler*, not=20 *of the platform*. You *hope* that your compiler vendor has made int=20 the most efficient size for general purpose integer math. > it is my imagination, I'am in the wrong way ? > =A0 > another question, is sizeof(int) =3D=3D sizeof(void*) ? > sizeof(void*) must be : size of memory bus address > so sizeof(int).... Once again, not necessarily. "void *" is a logical construct "of the=20 compiler*. You would expect a void * to be as many bits as necessary=20 to express the entire memory footprint of the computer architecture,=20 but there is no reason why it couldn't be either larger or smaller,=20 depending upon the compiler vendor. A straightforward (if evil)=20 example would be the segmented 8088 architecture, where the base memory=20= footprint was 1024K, but the RAM footprint was generally 640K, and full=20= pointers were 32 bits (16 bit segment, 16 bit offset). A 20-bit=20 pointer would have sufficed for the base memory footprint, but could=20 not have properly expressed all segment:offset pairs If you are trying to make sure that your code will run equally=20 efficiently on *all platforms* and *all compilers*, you are (probably=20 wasting your time) probably best off relying on "int" and "void *" and=20= not worrying about how they match to the platform until you have a=20 specific platform and compiler combination in mind. > -------------------------- > Lagarde S=E9bsatien > Neko entertainment > Junior programmer > > ----- Original Message ----- > From: Mick West > To: gam...@li... > Sent: Thursday, June 26, 2003 8:48 PM > Subject: RE: [GD-General] meaning of sizeof(int) on all plateform > > 128 bits would give you 16 bytes, not 32. > =A0 > On the PS2 an int is generally 32 BITS,=A0 (4 bytes), which is maybe=20= > where the confusion arose. > =A0 > Mick > > > -----Original Message----- > From: gam...@li...=20 > [mailto:gam...@li...] On Behalf Of=20= > Gareth Lewin > Sent: Thursday, June 26, 2003 11:42 AM > To: gam...@li... > Subject: RE: [GD-General] meaning of sizeof(int) on all plateform > > sizeof(int) =3D size of integer value. As defined by the compiler=20 > vendor. There is no "Correct" way to set the size of int. > > -----Original Message----- > From: Lagarde S=E9bastien [mailto:Lag...@wa...] > Sent: 26 June 2003 19:36 > To: gam...@li... > Subject: [GD-General] meaning of sizeof(int) on all plateform > > Hello all, > I have some problem to define what represent sizeof(int). > =A0 > IMO sizeof(int) =3D=3D memory bus address width > =A0 > but on platforme like PS2, you have a bus of 128 and sizeof(int) =3D=3D = 32. > =A0 > i have seen elsewherre that sizeof(int) =3D=3D size of a register. > =A0 > Is someone have some information on this point ? > thanks > ------------------------------- > Lagarde S=E9bastien > Neko entertainment > Junior programmer > =A0 > > -- Engines of Mischief Consulting =20 <http://www.enginesofmischief.com> Mischievous Ramblings =20 <http://www.enginesofmischief.com/blogs/ramblings> The Engine of Mischief =20 <http://www.enginesofmischief.com/engine> Mischief's Travelblog =20 <http://www.enginesofmischief.com/blogs/travelblog> I pledge allegiance to the flag of the multinational corporations and to the profit for which they stand, one interlocking directorate under no government, indivisible, with monopoly and cheap labor for=20 all. -- U. Utah Phillips, "Stupid's Pledge" |
From: J C L. <cl...@ka...> - 2003-06-30 01:58:42
|
On Thu, 26 Jun 2003 15:24:45 -0700 Evan Robinson <ev...@en...> wrote: > If you are trying to make sure that your code will run equally > efficiently on *all platforms* and *all compilers*, you are > (probably=20 wasting your time) probably best off relying on "int" and > "void *" and not worrying about how they match to the platform until > you have a=20 specific platform and compiler combination in mind. If you are going that route, also make sure that you're not assuming that the local system has a flat memory model, that pointers are simple integral types, that two pointers which have different internal bit-patterns are necessarily unequal (they can be), that the comparison of two pointers not from the same allocation buffer is valid (its not), and that NULL is all bits zero at run time (it may not be). -- J C Lawrence ---------(*) Satan, oscillate my metallic sonatas. cl...@ka... He lived as a devil, eh? http://www.kanga.nu/~claw/ Evil is a name of a foeman, as I live. |
From: J C L. <cl...@ka...> - 2003-06-30 01:58:33
|
On Thu, 26 Jun 2003 22:12:52 +0200 iso <iso-8859-1> wrote: > another question, is sizeof(int) =3D=3D sizeof(void*) ? sizeof(void*) > must be : size of memory bus address so sizeof(int).... No. There's no requirement for pointers to be integral types, and in fact on several platforms pointers are variously complex structures and not integral at all. -- J C Lawrence ---------(*) Satan, oscillate my metallic sonatas. cl...@ka... He lived as a devil, eh? http://www.kanga.nu/~claw/ Evil is a name of a foeman, as I live. |
From: <phi...@pl...> - 2003-06-26 19:43:31
|
IIRC, the only thing you can guarantee about the various int sizes is t= hat: sizeof(long) >=3D sizeof(int) >=3D sizeof(short) >=3D sizeof(char) similarly for floats: sizeof(double) >=3D sizeof(float) Cheers, Phil = Gareth Lewin = <GL...@cl... = .uk> = To Sent by: gam...@li...urc= efo gamedevlists-gene rge.net = ral-admin@lists.s = cc ourceforge.net = Subj= ect RE: [GD-General] meaning of = 06/26/2003 11:42 sizeof(int) on all plateform = AM = = = Please respond to = gamedevlists-gene = ra...@li...urcef = orge.net = = = sizeof(int) =3D size of integer value. As defined by the compiler vendo= r. There is no "Correct" way to set the size of int. -----Original Message----- From: Lagarde S=E9bastien [mailto:Lag...@wa...] Sent: 26 June 2003 19:36 To: gam...@li... Subject: [GD-General] meaning of sizeof(int) on all plateform Hello all, I have some problem to define what represent sizeof(int). IMO sizeof(int) =3D=3D memory bus address width but on platforme like PS2, you have a bus of 128 and sizeof(int) =3D=3D= 32. i have seen elsewherre that sizeof(int) =3D=3D size of a register. Is someone have some information on this point ? thanks ------------------------------- Lagarde S=E9bastien Neko entertainment Junior programmer = |