Re: Moving from C++ to VC++



On Thu, 9 Jun 2005 09:23:35 +0200, Hendrik Schober wrote:

> One would assume (that is, I would anyway) the
> native integer size on a 64bit platform to be
> 64bit. AFAIK, according to the C/C++ standards,
> even 'int' should be 64bit then. I agree that
> the usefulness of this is at least debatable.
> (Even though I would prefer 'int' to be the
> native integer type of the platform. If you need
> less than that, use 'short' or 'int32_t' or
> whatever.)

The main argument for int reflecting the "native" word size has been
efficiency. Anyone know how well these 64 bit CPUs implement 32 bit data
types?

> But I really don't see any excuse for not making
> 'long' 64bit on a 64bit platform.

Portable code can't assume long is larger than 32 bits. If you care about
anything beyond the minimum sizes, you have no business using the native
types. I know we all violated that with int and 32 bit platforms, but times
change. I can't remember the last time I wrote "long" on a 32 bit platform,
where I know int is 32 bits, and long is the same size. Well, that's not
entirely true. Like a lot of people, I assumed size_t would fit in an
unsigned long when using printf and friends and cast accordingly. That
assumption does fail in Win64, but hopefully the compiler will warn about
the possible (very rare) truncation.

--
Doug Harrison
Microsoft MVP - Visual C++
.



Relevant Pages

  • Re: Moving from C++ to VC++
    ... even 'int' should be 64bit then. ... native integer type of the platform. ... I'm Schobi at suespammers dot org ...
    (microsoft.public.vc.language)
  • Re: Moving from C++ to VC++
    ... >> even 'int' should be 64bit then. ... >> native integer type of the platform. ... The absurdity here is that you cannot even write portable code at all, ...
    (microsoft.public.vc.language)
  • Re: Moving from C++ to VC++
    ... If it is the longest integer. ... platform, I want the longest integer type ... Now /I/ would like to have 'int' being the ... Adhering to what computing standards' intention ...
    (microsoft.public.vc.language)
  • Re: I2C bus implementation (for MPC82xx)
    ... > PowerMac (see the patches that just went in rewriting the PowerMac i2c ... > smbus API, but then, do you really want to use an existing i2c driver? ... For the resources I have used platform definition. ... +static int ...
    (Linux-Kernel)
  • Re: Using OleDBParameter in a simple UPDATE statement
    ... apparently the SQL commands via the .NET OleDb objects w/MySQL are required ... Actually that is specific to the underlying database you are ... Also you might already know this, but an int to one ... > platform might be not an int some other platform. ...
    (microsoft.public.dotnet.framework.adonet)

Loading