functionaility of macros

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aania
    New Member
    • May 2010
    • 1

    #1

    functionaility of macros

    #define LOWORD(l) ((WORD)(l))
    #define HIWORD(l) ((WORD)(((DWORD )(l) >> 16) & 0xFFFF))

    Explain functionality of both of these macros
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    I can't do any better than a Google of HIWORD and LOWORD.

    Keep in mind that these are very old Windows macros back when 16-bit machines were the latest thing.

    I personally have never used this thing.

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      Hmmm actually I think you will find that these macros are actually part of the WIN32 API for 32 bit machines. Quite useful for decoding such things and the wParam of WM_COMMAND and other message parameters where often 2 16bit parameters were carried in a single 32bit value.

      Comment

      • donbock
        Recognized Expert Top Contributor
        • Mar 2008
        • 2427

        #4
        Personally, I would have defined LOWORD differently:
        Code:
        #define LOWORD(I) ((WORD)((I) & 0xFFFF))
        I prefer explicit masking to relying on overflow to work the way you expect.

        Comment

        Working...