Archived

This topic is now archived and is closed to further replies.

Viquel

size of int and long with a 64 bits processor ?

Recommended Posts

Viquel    122
Hi ! I ever heard that the size of an int is exactly the size of a word (for the processor). So it''s 32 bits with common processor and it should be 64 with the next generation processor. I take a look at the C# docs and saw that long are 64 bits. If that so it''s impossible to have data of 32 bits with a 64 bits processor. I suppose that I am wrong, but anyone knows exaclty how this will be for C/C++ ? If long will be 64 bits, it will be a real matter for portability. (Essentialy I/O with files) Thanks for your help, I''m just rewritting my SDK and don''t want to do this again in a few months.

Share this post


Link to post
Share on other sites
Spacecat    122
Quoth MSDN, under topic ''Fundamental types''.

quote:
short: Type short int (or simply short) is an integral type that is larger than or equal to the size of type char, and shorter than or equal to the size of type int.

int: Type int is an integral type that is larger than or equal to the size of type short int, and shorter than or equal to the size of type long.

long: Type long (or long int) is an integral type that is larger than or equal to the size of type int.



And then you get Microsoft specifics. It seems that the C/C++ standard does NOT force a long to be that many bits, or so on... However there apparently is a type __intn where n is the number of bits you want (8, 16, 32, 64).

It is a bit annoying, personally I like to define a few types like WORD, DWORD and BYTE when the number of bits is important.

=^.^= Leaders and teachers should remember: It is best to offer others what they Need, not what they Want.

Share this post


Link to post
Share on other sites
Viquel    122
ok, thanks for your answer.

I will try the __intn.

Oh that's great !
But not portable...
I saw something like that under Linux: __intn_t. A few #ifndef/#endif might help me.

[edited after few tests]

[edited by - Viquel on April 28, 2003 4:36:13 PM]

Share this post


Link to post
Share on other sites