Hello Pelle
In wtypes.h LANGID is declared as USHORT in winnt.h as WORD and you get a warning if you compile the following codefragmet with Warninglevel 2
Question 1: Why there are 2 declarations?
Question 2: Why there is this warning (If I looked correct both types are unsigned short in the end)
Question 3: Why it is possible to redeclare a type without a warning (if you use the compilerswitch /E you can see in the preprocessed file, that LANGID is 2 times declared!) and there is no errormessage (same behavior as in Jacob Navias compiler some times ago; now corrected!)
static int GetPrimaryUserLanguageID( void )
{
LANGID LanguageID;
LanguageID=GetUserDefaultLangID();
return PRIMARYLANGID(LanguageID);
}
warning #2215: Conversion from 'int' to 'unsigned short int'; possible loss of data.
winnt.h
...
typedef WORD LANGID;
...
wtypes.h
...
#ifndef _LANGID_DEFINED
#define _LANGID_DEFINED
typedef USHORT LANGID;
#endif
...
Hello Rainer,
1. Ask Microsoft! ;-)
2. It's briefly an expression before the assignment, and sizes smaller than an int will be converted to an int - then it's converted back for the assignment. The compiler probably shouldn't complain, but I don't know how to fix it cleanly right now (without loosing this useful warning in other contexts, and without duplicating tons of code...).
3. Not in standard C mode (default). In Microsoft mode (/Ze) it's possible to redeclare using the same type (same characteristics) - otherwise you get an error. This is all by design.
Pelle