Jump to content
  • Advertisement
Sign in to follow this  
dk32321

UINT,LPCSTR,DWORD what are they?

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

I have seen these data types alot, i am pretty sure they are data types, can somebody tell me what they are and what they do

Share this post


Link to post
Share on other sites
Advertisement
Yes, they're just data types.

UINT is an unsigned integer.
LPCSTR is a pointer to a constant string (char* or wchar_t* for unicode).
DWORD is a double word (a 32 bit unsigned integer).

Share this post


Link to post
Share on other sites
They are a strange mix of conventions (what follows are TYPICAL definitions):


typedef unsinged int UINT; // Unsigned INTeger
typedef char * LPCSTR; // Long Pointer to Character String
typedef unsigned long DWORD; // DoubleWORD


In Microsoft's Hungarian Notation scheme for naming variables, the prefix 'lp' stands for "long pointer", 'c' stands for "character" and 'u' stands for "unsigned". From the old days of programming, pointers could be long or short, depending on how far away in the absolute memory address your data was (due to the convoluted addressing schemes of old Intel chips). Nowadays, ALL pointers are long pointers, but Microsoft insists on still using "lp"!

A doubleword is two words, and what a "word" is exactly is often ambiguous. Typically, a word is the "bittage" of your processor, so if you have a 32-bit processor then the word size is 32 bits. However, a word can also mean 16 bits, which is what I believe the word size was when people started using "word" and "doubleword" to describe memory. Hence, DWORD is typically defined as 32 bits.

The idea behind using these typedefs is twofold. First, they are a convenience to type! Second, and more importantly, they let your program be easily updated to new architectures. For instance, on some machines an "int" may not be 32 bits! Hence, if you used the LPCSTR convention to declare all of your variables and you suddenly found that you actually wanted your strings to be Unicode, you can just change the definition to "long *" and it would change every variable declaration in your program!

Share this post


Link to post
Share on other sites
UINT = unsigned int
LPCSTR = char* (long pointer to a C style string... C style = ends with a 0)
DWORD = unsigned long int (double word)

EDIT: sorry, too late.

Share this post


Link to post
Share on other sites
I thought I'd comment on the above two posts as well, since they bring up interesting notational points.

>> LPCSTR = char* (long pointer to a C style string... C style = ends with a 0)
The typical prefix for a "ends with a 0" string is 'z'. Hence, a "long pointer to a 0-terminated character string" is LPZSTR.

>> LPCSTR is a pointer to a constant string (char* or wchar_t* for unicode).
The typical prefix for "constant" is 'const' or 'k' (note these are typically only for formal parameters). Hence, a "constant long pointer to a character string" would be: KLPCSTR. This prefix is rarely used, however.

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!