Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

GOOSEDUMP

Advantages of...

This topic is 6168 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

what are the advantages of using DWORD? I''m looking at a lot of code that use DWORD instead of int/long.... I''m wonderying why? What are the benifits? What are the downfalls? What type of situaion would you want to use a DWORD? Thanks ladies and gents..

Share this post


Link to post
Share on other sites
Advertisement
A BYTE/WORD/DWORD are always the same size. Size of an int or something is dependent on compile/platform. This will usually not matter, but if you want to write/read from a file 32-bits, you can''t count on int working. For example, if I remember correctly, the ints in a file were 16-bit, and i was reading them as 32-bit values. The program would compile and work at school, but not at home, due to this problem.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think Microsoft made it up so they could know for a fact how "big" the variable was.

WORD came from 16 bit Windows, and is 16 bits wide.

DWORD is 32 bits wide.

They did this because the size of "int" or "long" isn''t fixed.

As far as I know, someone correct me if I''m wrong please, but ints are guaranteed to be at least 32 bits, and long is guaranteed to be at least as wide as an int.

- Pete

Share this post


Link to post
Share on other sites
This whole thing bothers me abit. Last time I was programing
I didn''t have DWORD and WORD. I would like to stop typeing out
things like unsigned int but I worried that I might cause some
incompatiblity problem like mentioned before. Oh well. Guess
I could stop being lazy and look it up.

Share this post


Link to post
Share on other sites
in "Windef.h"....

typedef unsigned long DWORD;

ie, its a macro...



"It''s only after you''ve lost everything that you''re free to do anything." Tyler Durden

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by _Zerapolis_
in "Windef.h"....

typedef unsigned long DWORD;

ie, its a macro...


Not a macro, a typedef
a macro looks like:

#define DWORD unsigned long

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!