Results 1 to 6 of 6

Thread: Strange HWND...

  1. #1

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    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?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Zaei
    Guest
    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.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    What do they say there Zaei? I'd say STRICT
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    why would anyone not use STRICT?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I used STRICT since I found out about it
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width