Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conflict with DrawText function

Tags:

c++

winapi

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 is an unresolved external symbol for a DrawTextW method of this class.

I've seen this before with other methods ending in "Text" where it is looking for either a FooTextW or FooTextA method instead of the FooText method I defined. My assumption is that somewhere in the Windows headers there is a macro definition assigning FooText to FooTextW or FooTextA based on some other definition.

Aside from renaming my function (which is what I did in the past), does anybody have any good ideas for getting around this issue?

Thanks.

Joe

like image 416
Joe Corkery Avatar asked Aug 07 '26 07:08

Joe Corkery


1 Answers

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).

like image 199
i_am_jorf Avatar answered Aug 10 '26 01:08

i_am_jorf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!