Reputation: 6960
I just found out that the following is valid C++
typedef const char* PSTR, *LPSTR;
my question is: are PSTR and LPSTR the same alias?
Why if I change it to
typedef const char* PSTR, LPSTR;
I get that LPSTR is a char??
Upvotes: 4
Views: 108
Reputation: 42769
That is why I always stick the *
to the name and not to the type.
When you type
typedef const char *PSTR;
you must read that *PSTR
is a const char
, so PSTR
is the address of a const char
.
So if you type
typedef const char *PSTR,
*LPSTR,
OTHER;
OTHER
and *LPSTR
are const char
s just as *PSTR
.
Upvotes: 3
Reputation: 170084
Yup it's a char
. The same rules for deducing the type of a variable in variable definitions apply in a typedef definition.
Upvotes: 0
Reputation: 766
typedef is NOT alias..so if
typedef const char* PSTR, LPSTR;
PSTR is a pointer, LPSTR is a char
Upvotes: 0