#752 Including windows headers breaks <someclass>::GetMessage()

WSL
closed
nobody
None
wont-fix
Known_bugs
2013-01-22
2005-04-01
No

from winuser.h:

WINUSERAPI BOOL WINAPI GetMessageA(LPMSG,
HWND,UINT,UINT);

and later:

#define GetMessage GetMessageA

If you happen to use a class with a member function
named GetMessage(), the compiler will fail, complaining
about a missing GetMessageA() function, as soon as the
Windows API headers are included.

Replacing the above macro with an inline function
definition fixes this (at no cost):

inline BOOL GetMessage(LPMSG A, HWND B, UINT C,
UINT D) { GetMessageA(A, B, C, D); }

IMHO this scheme should be applied to all Windows API
headers. I can imagine a perl script or the like could do
this automagically.

Discussion

  • Luke Dunstan

    Luke Dunstan - 2005-04-03

    Logged In: YES
    user_id=30442

    That won't work for C code, and it is undesirable to start
    introducing new differences between the way our headers
    work with C and C++. These macros are also present in
    other Windows compilers so changing them could introduce
    incompatibilities there too (some code may rely on the
    macros existing).

    As far as I'm concerned, the macros are part of the Windows
    API, so if you wish to use the API then you must deal with
    the macros yourself (e.g. with #undef).

     
  • Danny Smith

    Danny Smith - 2005-06-18
    • status: open --> closed-wont-fix
     
  • Earnie Boyd

    Earnie Boyd - 2013-01-22
    • status: closed-wont-fix --> closed
    • resolution: --> wont-fix
    • category: --> Known_bugs
    • milestone: --> WSL
     
  • Earnie Boyd

    Earnie Boyd - 2013-01-22
    • labels: w32api (deprecated use WSL) -->
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks