I'm trying to understand if these types are all the same. I have this function from windows.h: GetCommandLine()
, in UNICODE
mode, and it returns a LPWSTR
. Now, if I dig deeper I can see how LPWSTR
is wchar_t*
and if I go even further, I find out that wchar_t
is unsigned short
(16 bytes) or unsigned long
(32 bytes). Yet, if I do this:
unsigned short* SysComm = GetCommandLine();
I get this error:
cannot convert from 'LPWSTR {aka wchar_t*} to 'short unsigned int*' in initialization
So, does the compiler follow the same logic to find out that LPWSTR
is unsigned short*
in the end or am I wrong?
wchar_t
is a distinct type that is defined to have the same properties as one of the other integer types.
Type
wchar_t
is a distinct type [...]. Typewchar_t
shall have the same size, signedness, and alignment requirements (3.11) as one of the other integral types, called its underlying type.
So you can't implicitly convert from a wchar_t*
to a short*
just as much as from an int*
to a short*
.