Hello all, just looking for some help understanding the beginning and end of this description. It's a typical example of what i see looking at the WINAPI and DX documentation and want to make sure I understand it.
As i read it, tagWNDCLASSEX is a typedef (renaming) of the struct WNDCLASSEX (because WNDCLASSEX immediate follows the {}braces). If that is correct, what does the pointer at the end represent?
This style is common because C is weird with struct namespaces.
In C, a struct name must be prefixed with 'struct' or else it will not be recognized:
1 2 3 4 5 6 7
struct Foo
{
//...
};
Foo a; // Error: 'foo' not defined
struct Foo b; // OK
To get around this... C coders often typedef their struct names to another (or the same) struct name just to get it in the global namespace so you don't have to prefix it with the 'struct' keyword whenever you want to use it.
1 2 3 4 5 6 7 8
struct Foo
{
//...
};
typedefstruct Foo Bar;
Bar a; // OK. Same as saying "struct Foo a;"
Furthermore, you can typedef a pointer the same way:
1 2 3 4 5
typedefstruct Foo* Ptr;
Ptr p; // OK... same as saying "struct Foo* p;"
// or "Bar* p;"
// ie: it creates a pointer to a struct
What MSDN is doing is shortcutting all of that by putting in all the same statement: