typedef is used to create an alternative name for a type. After the typedef, ContactField can be used to mean an array of 256 char. ContactField foo; and char foo[0x100]; will do the same thing.
Jesus!, why type INT instead of int??
why VOID instead of void LOL
why don't they just do typedeftypedef TYPEDEF lol ahahahh
API should be understandable but it seems they don't care about design.
they said Win32 API is hard to learn, O_O lol, of course it's hard since they screwed up everything with their ugly design so no-one can understand it except $MS kids.
$MS code is an UGLY CRAP.
they don't even respect C++ standard, they include headers into other headers in their flawor.
they don't support exception list which is standard from C++03.
tipical $MS:
you won't belive for what they use #define:
A lot of what they do is to support legacy systems. Also, a lot of that stuff was never intended for C++. It's C so don't complain that they don't follow the latest c++ standard. It's made as generic as possible to make porting to other languages as simple as possible.
Sure you may not like that INT doesn't turn blue in your IDE like int but the meaning is just as clear.
Now typedefint INT may seem trivial, but they are abiding by a coding standard here. Not all systems and compilers treat int as 4 bytes, however INT must be 4 bytes for some things to work so they use a series of defines to ensure that it turns out this way. Consider the following from WinNT.h:
1 2 3 4 5 6
#ifndef _MAC
typedefwchar_t WCHAR; // wc, 16-bit UNICODE character
#else
// some Macintosh compilers don't define wchar_t in a convenient location, or define it as a char
typedefunsignedshort WCHAR; // wc, 16-bit UNICODE character
#endif
We change the type of WCHAR depending on the system that we are building this on. That's good design, not UGLY CRAP.
They didn't write Windows.h to be confusing, they wrote it to work, and they wrote it to work on any system from any era with any language. It does that and so they are successful.
#define VOID void and typedefvoid* PVOID ; are not just trivial, they are absurd.
While typedefint INT ; for a 32 bit integral type is not trivial, C's int32_t in <stdint.h> would have been a lot better - at least it says what it means.
They didn't write Windows.h to be confusing, they wrote it to work, and they wrote it to work on any system from any era with any language
*BULLSHIT*
there are C++ API's and libs which support far more then Win32 API does and those does not look even close so ugly as Win32 API.
$MS API has serious problems with design which can not be redisigned any more. at least not so easy.
Well of course they look for compatibility and thats why all those typedef and #defines but anyway there are much better approaches, and $MS programers have chosed the most ugliest way.
OH yeah,
look at .NET framework design. all the mistakes maded in Win32 API and all that experience has ben transported to .NET, well they won't make a mistake one more time. look at .NET how polished is it now. no UGLY code at all. it's most beautiful API I've seen so far.(design I mean)
you are saying typedefint INT so you can be shore that INT will allways be 4 Bytes.
well why does then exist shortand long? shortis allways 2B while longis allways 4B isn it? (correct me if not)
you don't have to use intat all. use shortand long and forget about int. no typedefneeded.
True int can be different with different configurations. That's what we are using the typedef for. While typedefint INT may not be the entire solution, having a few options which are seperated with some #ifdef statements will help us to select what INT will be. typedefint INT is just one (and probably the most common) possibility.
stick with C++ standard as most non-$MS programers do
No. As I said, the windows headers are meant to be GENERIC. They are VERY commonly used with C and are often ported to other languages. Putting in c++ specific code would destroy this functionality.
The people who wrote those headers and the Win API are very good programmers, they don't just add complexity without reason. Just because you may not need 99% of the stuff they write doesn't mean that other's don't.
Microsoft did what it did to have full control on their data types. If in the future an int changes size in some compiler, they can update the SDK so INT points to the right 4-byte int in that specific compiler. Same for all other data types. I know, the C++ standard ensures the size of certain data types, but still the point is valid.
It is not poor design, it is ultimate indirection. It is very clever, if you ask me. Most of us don't have such a far-reaching vision.
In any case, that's just my opinion. Flame it away if you must. :-P