57

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?

nvoigt
  • 75,013
  • 26
  • 93
  • 142
Haim Bender
  • 7,937
  • 10
  • 53
  • 55
  • 7
    A a DWORD is not machine, platform, nor SDK dependent. – Mooing Duck Jul 16 '13 at 17:40
  • This is a nitpick but technically this question applies to either C or C++, it might be better to remove the C++ tag or add the C tag, but I'm not sure which one is better. – jrh Dec 26 '17 at 21:05

4 Answers4

70

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).

Daniel Naab
  • 22,690
  • 8
  • 54
  • 55
Nir
  • 29,306
  • 10
  • 67
  • 103
  • The actual ranges are listed [here](https://msdn.microsoft.com/en-us/library/s3f49ktz.aspx). – Laurie Stearn Apr 02 '16 at 12:19
  • @LaurieStearn I think this article is about the data types that the Microsoft compilers use internally, not the winapi data types like `DWORD`. – jrh Dec 26 '17 at 21:02
  • 2
    Yeah, the article in the answer's linked [official list](https://msdn.microsoft.com/en-us/library/aa383751(VS.85).aspx) now has the ranges: Quote: **DWORD: A 32-bit unsigned integer. The range is 0 through 4294967295 decimal.** – Laurie Stearn Dec 27 '17 at 03:02
  • DWORD is on the windows libraries equal to an "unsigned long" – jaques-sam Dec 05 '18 at 12:23
17

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.

Mark Ingram
  • 71,849
  • 51
  • 176
  • 230
12

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

Rob Walker
  • 46,588
  • 15
  • 99
  • 136
1

Windows API defines DWORD sizes as follows:

  • x86: sizeof(DWORD) = 4
  • x64: sizeof(DWORD) = 4
ogggre
  • 2,204
  • 1
  • 23
  • 19