• Advertisement
Sign in to follow this  

A question on the DWORD data type

This topic is 4253 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

From googling I found that DWORD has two distinct meanings. One is that it is a "double word" able to hold 32 bits of data, and the other states that DWORD is a typedef for an unsigned long. And since I am going into DirectX/Win32, I just wanted to know if it was right to assume DWORD as a unsigned long. Sorry if this is an utterly stupid question, but somebody has to ask. -Thanks

Share this post


Link to post
Share on other sites
Advertisement
I do believe that, in the Win32 API, 'DWORD' is a 'typedef' for 'unsigned long'. But when you deal with 'DWORD' in ASM, I believe it's a "double word". Or maybe "unsigned long" is equivelant to "double word"?

I don't know for sure. That's my guess though. I am pretty sure about the typedef'ed 'DWORD', though.

Share this post


Link to post
Share on other sites
Oh ok, thanks!

I wanted to assume the two meanings were associated with one another, but my doubt kills me every time.

Share this post


Link to post
Share on other sites
Quote:
Original post by TFS_Waldo
in ASM, I believe it's a "double word"


i think that goes for windows too, because a WORD has 16 bits ( unsigned short if i remember correct^^ ) wich is exactly half of DWORD with 32 bits.

Share this post


Link to post
Share on other sites
In the strict sense a DWORD is only a double word on 16-bit machines (which is where it was first used). A 'word' is the smallest amount of addressible memory which works out to be the bitness of your processor. 32-bit processors have a word size of 32-bits since a 32-bit processor cant address less than 32 bits.

That being said, a DWORD will always be 32 bits.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:

MSDN officially says
32-bit unsigned integer.

This type is declared in WinDef.h as follows:

typedef unsigned long DWORD;

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The link in my post got erased. Here it is again:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/windows_data_types.asp

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Quote:

MSDN officially says
32-bit unsigned integer.

This type is declared in WinDef.h as follows:

typedef unsigned long DWORD;


They're only somewhat right. It really depends on the compiler's own implementation of long, but usually long equals a 32 bit integer (it does in msvc, gcc and bcc so it's safe to say yes in that matter if you're using one of those).

Share this post


Link to post
Share on other sites
Quote:
Original post by nife
Quote:
Original post by Anonymous Poster
Quote:

MSDN officially says
32-bit unsigned integer.

This type is declared in WinDef.h as follows:

typedef unsigned long DWORD;


They're only somewhat right. It really depends on the compiler's own implementation of long, but usually long equals a 32 bit integer (it does in msvc, gcc and bcc so it's safe to say yes in that matter if you're using one of those).


No, they are totally right. If the MS doc says that a DWORD is a 32 bit unsigned integer then it IS a 32 bit unsigned integer. The implementation of a DWORD may vary (it may depend on the compiler), but it still have to obbey to the base definition.

Regards,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement