How large is a DWORD with 32- and 64-bit code?
Asked Answered
D

4

62

In Visual C++ a DWORD is just an unsigned long that is machine, platform, and SDK dependent. However, since DWORD is a double word (that is 2 * 16), is a DWORD still 32-bit on 64-bit architectures?

Damp answered 2/9, 2008 at 12:50 Comment(1)
A a DWORD is not machine, platform, nor SDK dependent.Nones
K
72

Actually, on 32-bit computers a word is 32-bit, but the DWORD type is a leftover from the good old days of 16-bit.

In order to make it easier to port programs to the newer system, Microsoft has decided all the old types will not change size.

You can find the official list here: http://msdn.microsoft.com/en-us/library/aa383751(VS.85).aspx

All the platform-dependent types that changed with the transition from 32-bit to 64-bit end with _PTR (DWORD_PTR will be 32-bit on 32-bit Windows and 64-bit on 64-bit Windows).

Kyanite answered 2/9, 2008 at 13:2 Comment(4)
The actual ranges are listed here.Bluff
@LaurieStearn I think this article is about the data types that the Microsoft compilers use internally, not the winapi data types like DWORD.Drucill
Yeah, the article in the answer's linked official list now has the ranges: Quote: DWORD: A 32-bit unsigned integer. The range is 0 through 4294967295 decimal.Bluff
DWORD is on the windows libraries equal to an "unsigned long"Icarian
A
18

It is defined as:

typedef unsigned long       DWORD;

However, according to the MSDN:

On 32-bit platforms, long is synonymous with int.

Therefore, DWORD is 32bit on a 32bit operating system. There is a separate define for a 64bit DWORD:

typdef unsigned _int64 DWORD64;

Hope that helps.

Angadreme answered 2/9, 2008 at 12:55 Comment(0)
T
13

No ... on all Windows platforms DWORD is 32 bits. LONGLONG or LONG64 is used for 64 bit types.

Touchwood answered 2/9, 2008 at 12:55 Comment(3)
it has nothing to do with Windows, it's Intel termQuadrivial
@Abyx: the typedef DWORD is very Windows.Zins
@rubenvb, oh and why it's called DWORD and not something else like QBYTE or DUBWD?Quadrivial
S
1

Windows API defines DWORD sizes as follows:

  • x86: sizeof(DWORD) = 4
  • x64: sizeof(DWORD) = 4
Sacrifice answered 15/8, 2022 at 20:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.