How are DWORD and WORD defined in c++?
How are DWORD and WORD defined in c++?
unsigned long
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.
They're not defined in C++.
http://en.wikipedia.org/wiki/Dword_%28Computer%29
http://en.wikipedia.org/wiki/Word_%2...ter_science%29
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.*
Isn't a DWORD just a typedef for unsigned long?
EDIT: Ik... it's machine dependant. gotcha
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.
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.Originally Posted by Mario F.
The important issue is the DWORD and WORD are not c or c++ standard macros.
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.
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.
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.Originally Posted by Mario F.
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.*
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