size of int and long with a 64 bits processor ?

Started by
3 comments, last by Viquel 20 years, 12 months ago
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.
Advertisement
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.
=^.^= Leaders and teachers should remember: It is best to offer others what they Need, not what they Want.
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]
C++0x (and I think c99 already has them) will have fixed-size ints.

I have a file called integers.hpp file with custom typesef''s in it for fixed-sizes.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
To elaborate on the *nix and C99 fixed size integers, see this header file.

This topic is closed to new replies.

Advertisement