Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > Windows 64bit > sizeof(int) on x64 system?

Reply
Thread Tools

sizeof(int) on x64 system?

 
 
David
Guest
Posts: n/a
 
      08-09-2006
I've built some code under Visual Studio C++ (2005) and sizeof(int) is
4 bytes whether the code is built for 32 or 64 bit platforms. (I'm
running on a 64 bit machine.)

I was of the impression that the Ansi spec defines 'int' to be the same
as the native word size of the machine. Am I wrong or is there a
compile flag or manifest that would get sizeof(int) to be 8?

Thanks.

- David

 
Reply With Quote
 
 
 
 
Tony Sperling
Guest
Posts: n/a
 
      08-09-2006
I think you are right. I can't tell you what it is, but most likely a
pre-processor directive.


Tony. . .


"David" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> I've built some code under Visual Studio C++ (2005) and sizeof(int) is
> 4 bytes whether the code is built for 32 or 64 bit platforms. (I'm
> running on a 64 bit machine.)
>
> I was of the impression that the Ansi spec defines 'int' to be the same
> as the native word size of the machine. Am I wrong or is there a
> compile flag or manifest that would get sizeof(int) to be 8?
>
> Thanks.
>
> - David
>



 
Reply With Quote
 
 
 
 
Bo Persson
Guest
Posts: n/a
 
      08-09-2006

"David" <(E-Mail Removed)> skrev i meddelandet
news:(E-Mail Removed) ups.com...
> I've built some code under Visual Studio C++ (2005) and sizeof(int)
> is
> 4 bytes whether the code is built for 32 or 64 bit platforms. (I'm
> running on a 64 bit machine.)
>
> I was of the impression that the Ansi spec defines 'int' to be the
> same
> as the native word size of the machine.


For some definition of 'native'.

For x64, a 32 bit int *is* the native size, as it produces the
smallest code size. To use 64 bit operands, the machine code must
include a size override prefix.

> Am I wrong or is there a
> compile flag or manifest that would get sizeof(int) to be 8?


No, there is not.

On some systems, Linux in particular, sizeof(long) might be 8. With MS
C++, sizeof(long)==sizeof(int)==8.


Bo Persson


 
Reply With Quote
 
Bo Persson
Guest
Posts: n/a
 
      08-09-2006

"Bo Persson" <(E-Mail Removed)> skrev i meddelandet
news:OyrjQn%(E-Mail Removed)...
>
> "David" <(E-Mail Removed)> skrev i meddelandet
> news:(E-Mail Removed) ups.com...
>> I've built some code under Visual Studio C++ (2005) and sizeof(int)
>> is
>> 4 bytes whether the code is built for 32 or 64 bit platforms. (I'm
>> running on a 64 bit machine.)
>>
>> I was of the impression that the Ansi spec defines 'int' to be the
>> same
>> as the native word size of the machine.

>
> For some definition of 'native'.
>
> For x64, a 32 bit int *is* the native size, as it produces the
> smallest code size. To use 64 bit operands, the machine code must
> include a size override prefix.
>
>> Am I wrong or is there a
>> compile flag or manifest that would get sizeof(int) to be 8?

>
> No, there is not.
>
> On some systems, Linux in particular, sizeof(long) might be 8. With
> MS C++, sizeof(long)==sizeof(int)==8.

^^^^

****!

It looks kinda like an 8, but is really a 4 (four). Honest!


Bo Persson



 
Reply With Quote
 
James Robertson
Guest
Posts: n/a
 
      08-10-2006
The only thing the C and C++ standards define as far as type sizes is
concerned is:

sizeof char <= sizeof short <= sizeof int <= sizeof long

Win64 defines int and long to be 32-bit. Presumably for compatibility
reasons as much as anything else. Be aware that size_t is 64-bit though.
(This is currently causing me a few headaches.)


(Another gotcha to watch out for is NULL still being defined as 0 instead of
0LL. Which is a real problem when you try to pass a NULL pointer to a
varargs function. The caller pushes a 32-bit integer 0, while the callee
tries to retrieve a 64-bit pointer 0. Oh the fun I had with that one...)



"David" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> I've built some code under Visual Studio C++ (2005) and sizeof(int) is
> 4 bytes whether the code is built for 32 or 64 bit platforms. (I'm
> running on a 64 bit machine.)
>
> I was of the impression that the Ansi spec defines 'int' to be the same
> as the native word size of the machine. Am I wrong or is there a
> compile flag or manifest that would get sizeof(int) to be 8?
>
> Thanks.
>
> - David
>



 
Reply With Quote
 
Homer J. Simpson
Guest
Posts: n/a
 
      08-10-2006
> (Another gotcha to watch out for is NULL still being defined as 0 instead
> of 0LL. Which is a real problem when you try to pass a NULL pointer to a
> varargs function. The caller pushes a 32-bit integer 0, while the callee
> tries to retrieve a 64-bit pointer 0. Oh the fun I had with that one...)


Stop it, you're creeping me out...


 
Reply With Quote
 
tha_specializt tha_specializt is offline
Junior Member
Join Date: Dec 2007
Posts: 2
 
      03-18-2010
Quote:
Originally Posted by Bo Persson
On some systems, Linux in particular, sizeof(long) might be 8. With MS
C++, sizeof(long)==sizeof(int)==8.
Wow, it appears you dont know what you're talking about ....

msdn.microsoft.com/en-us/library/aa383751%28v=VS.85%29.aspx

Both sizeof(int) and sizeof(long) == 4. Learn to use Google before you post things
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Windows XP x64 Drivers with Windows Server 2003 x64 Steve Graddy Windows 64bit 9 10-22-2005 04:27 AM
Windows Server 2003 X64 RC2 or SImply XP Professional X64 Edition =?Utf-8?B?UGFzY2Fs?= Windows 64bit 6 09-25-2005 05:33 PM
Upgrading x64 evaluation with full version of x64 prof? Daniel Herrmann Microsoft Certification 0 06-21-2005 08:10 PM
Ethereal for x64 -- or Network Monitor for x64 =?Utf-8?B?U21lYWdvbA==?= Windows 64bit 0 06-16-2005 11:30 PM
X64 trial to x64 full verion OEM =?Utf-8?B?TWFsY29sbQ==?= Windows 64bit 8 05-25-2005 04:31 PM



Advertisments