Can i get your opinion? [TL;DR post].

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

optLog
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 18
Joined: Wed Oct 06, 2010 3:40 am

Re: Can i get your opinion? [TL;DR post].

Post by optLog »

As someone who's currently studying the win32 api, I'd just like to mention this. A common theme I've seen in a few apis I've looked at is to use typedef to make the api easier to understand. For example, the GetMessage function returns BOOL. BOOL is really just a typedef of int. That way in addition to returning a true(1) or false(0) result the function can also return an error(-1). If a function returns BOOL then you know that normally it will return a true or a false result, but that it could (not every function of type BOOL will) also return an error. Data types like HINSTANCE and HWND are really just typedefs of void pointer, but with the typedef you have a better understanding of what a variable is going to be used for and what kind of object a function needs run.

Which version of this function do you find easier to understand?

Code: Select all

int ShowWindow(void*, int);
BOOL ShowWindow(HWND, int);
If you're relatively new to C/++ programming then you could learn quite a few cool programming techniques by studying win32, but that's not to say you couldn't learn them by learning another api.
Post Reply