Re: Length of data types for _WIN64

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 03/09/04


Date: Mon, 08 Mar 2004 22:09:07 -0500

char - 8 bits, 1 byte
short - 16 bits, 2 bytes
int, long - 32 bits, 4 bytes
long long - 64 bits, 8 bytes
void * - 64 bites, 8 bytes

They avoided the C stupidity of making "int" be platform-dependent. This was a mistake in
the design of C (which I had to deal with in porting PDP-11 code to the Vax in the early
1980s, and I said it was a mistake then, and it still is).

The ISO C standard defines limits.h to be

SCHAR_MIN -127
SCHAR_MAX 127
UCHAR_MAX 255
SHRT_MIN -32767
SHRT_MAX -32767
USHRT_MAX 65535
INT_MIN -32767
INT_MAX 32767
UINT_MAX 65535
LONG_MIN -2147483647
LONG_MAX 2147483647
ULONG_MAX 4294967295

and says that any implementation can "substitute other values for these but they must not
be less in absolute magnitude than the values shown, and must have the same sign".
[the table and quote come from Harbison & Steele, 4th edition, p.112].

Note the anomaly in the spec, in that SCHAR_MIN is -127, not -128, for example. So this
pretty much establishes the minimum sizes for the types, in bits. The ISO standard allows
int to be 16 bits, but a 32-bit implementation is free to define this to be a 32-bit
range.

Sam Harbison once worked on a compiler where sizeof(char) == sizeof(short) == sizeof(int)
== sizeof(long) == sizeof(long long) == 1, and SCHAR_MIN was a number which was somehting
like -2**80-1 (it was an 80-bit-word DSP chip).
                                joe

On Mon, 08 Mar 2004 19:34:19 GMT, "TT \(Tom Tempelaere\)"
<_N_OSPAMtiti____@hotmail.comMAPSO_N_> wrote:

>"David Lowndes" <davidl@example.invalid> wrote in message
>news:8vlo409dmkg4vgm0g68k6rmjqr86q47ev2@4ax.com...
>> >What lenghts are the primitive data types if _WIN64 is defined?
>>
>> Tom,
>>
>> Have a look at the topic titled "The New Data Types" in MSDN.
>>
>> Dave
>> --
>> MVP VC++ FAQ: http://www.mvps.org/vcfaq
>
>Ok, but they only mention the defined types, not primitve.
>
>I was talking about: short, int, long, long long.
>---
>Cheers,
>Tom Tempelaere
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm



Relevant Pages

  • Re: Are static array pointers thread safe?
    ... implementation, using the value a twice, once as the array name, once as a parameter) ... pointers thread safe /NT". ... checked by the read-write functions using an enum or static const int ... MVP Tips:http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Re: Windows Resizing
    ... >void CSvg::OnSize(UINT nType, int cx, int cy) ... >> CWebBrowser2 control. ... >> Victor. ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
    (microsoft.public.vc.mfc)
  • Re: screen flicker
    ... public static extern int SendMessage(System.IntPtr hWnd, ... System.IntPtr lParam); ... Bob Powell [MVP] ... > ByVal wParam As Int32, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Here is BitBlt() drawing?
    ... OnPaint message handler to be called properly. ... int cxIcon = GetSystemMetrics; ... MVP Tips:http://www.flounder.com/mvp_tips.htm ... I've added a Picture Control to my dialog... ...
    (microsoft.public.vc.mfc)
  • Re: Dear MVP - Web control performance enquiries
    ... I'm not an MVP but I can answer this for you. ... Dim int as Integer ... because the CLR won't have to perform the conversion 5 times. ...
    (microsoft.public.dotnet.framework.aspnet)