Dword / Word

This is a discussion on Dword / Word within the C++ Programming forums, part of the General Programming Boards category; How are DWORD and WORD defined in c++?...

  1. #1
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630

    Dword / Word

    How are DWORD and WORD defined in c++?

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,403
    unsigned long
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,403
    Isn't a DWORD just a typedef for unsigned long?

    EDIT: Ik... it's machine dependant. gotcha
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #5
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Quote Originally Posted by Mario F.
    Isn't a DWORD just a typedef for unsigned long?

    EDIT: Ik... it's machine dependant. gotcha
    DWORD is a macro defined in windows.h and specifically for MS-Windows os (although that does not prevent others from defining it too ). It is NOT part of the C or C++ standards, so the issue of machine dependency is not relevent. An unsigned long running on any computer that is running MS-Windows is the same size.

    The important issue is the DWORD and WORD are not c or c++ standard macros.

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,403
    Hmm... maybe we are being a little picky. WORD and DWORD, as you say are macros defined in windows.h. I understand they are not defined in C++, but can be declared by the use of macros.

    Maybe I was too lenient with the OP question. I didn't take it word by word (pun not intended). I believe the OP simply wanted to know an equivalent definition to WORD and DWORD.

    The answer is thus machine dependant. But is unsigned int and unsigned long respectively for the common 32bit machines with 16bits ints.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #7
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by Mario F.
    The answer is thus machine dependant. But is unsigned int and unsigned long respectively for the common 32bit machines with 16bits ints.
    The whole point of having the typedefs/macros is not to have everyone peeking up the skirt to see how it is defined, but instead to use the typedef/macro and let the implementation specfics be up to the implementor.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    The Win32 API specified DWORD to be an unsigned 32-bit type, and WORD to be an unsigned 16-bit type. The API is responsible for defining the typedefs (not macros) in a way that this holds true for every supported platform/compiler combination. (I believe, however, that only VC++ on x86, x64 and IA-64 are officially supported.)
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help calling function is asm
    By brietje698 in forum C++ Programming
    Replies: 24
    Last Post: 12-06-2007, 03:48 PM
  2. Inline asm
    By brietje698 in forum C++ Programming
    Replies: 5
    Last Post: 11-11-2007, 01:54 PM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Wrong Output
    By egomaster69 in forum C Programming
    Replies: 7
    Last Post: 01-28-2005, 05:44 PM
  5. storage size of regs is unkown
    By Vertex34 in forum C Programming
    Replies: 5
    Last Post: 11-04-2003, 09:17 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21