Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 424
Haim Bender Avatar asked Sep 02 '08 12:09

Haim Bender


People also ask

What is a DWORD in 64-bit?

In DOS and Windows programming, 16 bits is a "WORD", 32 bits is a "DWORD" (double word), and 64 bits is a "QWORD"; but in other contexts "word" means the machine's natural binary processing size, which ranges from 32 to 64 bits nowadays.

What is the size of a DWORD?

A DWORD is a 32-bit unsigned integer (range: 0 through 4294967295 decimal).

What is bigger than a DWORD?

Hope that helps. Show activity on this post. No ... on all Windows platforms DWORD is 32 bits. LONGLONG or LONG64 is used for 64 bit types.


2 Answers

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

like image 131
Nir Avatar answered Sep 21 '22 17:09

Nir


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.

like image 40
Mark Ingram Avatar answered Sep 22 '22 17:09

Mark Ingram