Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C/C++

C/C++ C/C++ Discussion

Reply
 
Thread Tools Display Modes
Old 08-04-2007, 02:01 PM   #1 (permalink)
Forum Expert
 
TheOutkastDev's Avatar
 
Join Date: Sep 2002
Location: Houston, Texas
Age: 22
Posts: 3,933
Default WORD, DWORD vs. short and int

What's the purpose of using WORD or DWORD over shorts or ints in C++?
TheOutkastDev is offline   Reply With Quote
Old 08-04-2007, 03:56 PM   #2 (permalink)
Newbie
 
Join Date: Jun 2006
Posts: 95
Default

I could be wrong (Zippy?) in my experience they have been interchangable. Maybe its only for referencing (compatibility) purposes.

For COM and dlls I use DWORD if its a non C# library.
__________________
Record for the sentence that makes the least sense - Go HERE
Kamron is offline   Reply With Quote
Old 08-06-2007, 08:23 PM   #3 (permalink)
Forum Expert
 
Join Date: Aug 2004
Location: Redmond, WA
Age: 21
Posts: 1,288
Send a message via AIM to Sep102 Send a message via MSN to Sep102
Default

There isn't a reason that they have to be used or anything of the sort. They're used for essentially two reasons:
  • That using them expresses the intent of the value better (for example, this parameter isn't meant to be a number, but a certain bit sequence [in the case of a WORD/DWORD] or this is meant to be a pointer to a sequence of values in memory [that could be anything; in the case of a WORD */DWORD *]).
  • That using them allows your code to be more easily ported to different architectures with different sizes for WORD's/DWORD's (which, of course, is likely something that's never going to happen with an average programmer's code, but it is a possibility nonetheless).

But, I basically just lied, they're mostly used because people see them in Microsoft's example code, in the tutorials for the WIN32 API, in the headers and in Intellisense™, so people use them just in case or to be consistent (or, once in a blue moon, for the bullets above).

And, they are interchangeable in general, but it's still a better idea to use the API's types when working with it (if just for consistency, assurance of correct types or superstition).

Last edited by Sep102; 08-06-2007 at 08:25 PM.
Sep102 is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5