thejinchao / turbolink

TurboLink is an unreal engine plugin enables Google gRPC work with Unreal Engine using C++ and Blueprint
MIT License
129 stars 32 forks source link

Windows conflict with GetMessage #32

Closed bwagstaff closed 6 months ago

bwagstaff commented 6 months ago

If the imported proto file has a function called GetMessage, TurboLink will generate a corresponding .h/cpp matching that interface, and including all of its standard includes.

Unfortunately, the include chain also pulls in WinUser.h, included through an upstream Windows.h include, which defines a macro:

#ifdef UNICODE
#define GetMessage  GetMessageW
#else
#define GetMessage  GetMessageA
#endif // !UNICODE

This ultimately causes the generated file to not compile because the macro has renamed the function.

This is a known problem within the Windows API, where many function names are redefined via macro to FunctionNameW or FunctionNameA, but still something that can cause problems with TurboLink. For now, I'm using #undef GetMessage after the include in the generated file, but others might find better workarounds or a proper solution that avoids the accidental upstream inclusion of windows.h.

thejinchao commented 6 months ago

My suggestion is to change the name of the function to avoid conflict with the Windows API. Seems that there is no better way.