-
Strange HWND...
did anyone notice before how the DECLARE_HANDLE macro works? It is used to declare the handle data types and is defined as follows:
Code:
#define DECLARE_HANDLE(name) \
struct _##name {int unused; }; typedef struct _##name * name;
Does anyone have an idea why MS uses that weird way to declare handles?
-
probably so that handles won't mix up with implicit cast, they use a lot of macros as shortcuts for declarations which makes it harder to read it unless you have read it all trough once.
-
There is actually a big rant going on over on GameDev.net on this sort of thing. The code you posted is in "#ifdef STRICT" pre processor tags. If STRICT is not defined, all HANDLE types (HWND, HDC, etc) are typedefed to HANDLE which is void*. So, when a function calls for an HDC, and STRICT is not defined, you can pass an HWND if you wanted, and the compiler wouldn't yell. If STRICT is defined, all HANDLE types (except HANDLE, its still void*) are now structs, and the compiler will yell if you mix them up.
Z.
-
What do they say there Zaei? I'd say STRICT :)
-
why would anyone not use STRICT?
-
I used STRICT since I found out about it :)