Conflict with DrawText function

后端 未结 2 1722
别那么骄傲
别那么骄傲 2021-01-21 05:33

I am developing a multi-platform application and in one component I have a class method called DrawText. Unfortunately, I get a linker error (on windows only) saying that there

相关标签:
2条回答
  • 2021-01-21 05:45

    You really only have two choices:

    #ifdef DrawText
    #undef DrawText
    #endif
    

    Or rename your function. Win32 uses macros which have no namespacing or scoping, so you're kinda stuck.

    We just re-name our functions.

    BTW: It's based on #ifdef UNICODE usually (or _UNICODE or a few other variants).

    0 讨论(0)
  • 2021-01-21 05:55

    Yes, this is a real problem with using Windows, and there's no way to turn it off since the headers all look like this:

    #ifdef UNICODE
    #define GetDlgItemText GetDlgItemTextW
    #else
    #define GetDlgItemText GetDlgItemTextA
    #endif
    

    So you're going to get the symbol defined either way. It would be very nice if you could #define something before #include'ing windows.h that turns this behavior off, but alas none exists.

    0 讨论(0)
提交回复
热议问题