I am wrapping the cpr http request library as an external module and running into compilation issues due to Unreal’s macros rewriting the word “verify” in one of the library’s header files.
I include the library in an Unreal .cpp file, wrapping the include in the third party includes directives:
Somewhere inside the cpr library, a class has a boolean member named verify. Unreal expands the word verify as a macro, introducing a syntax error when I compile and it finds this constructor.
Not sure if unreal plays well when it comes to mixing them with third-party stuff
In theory the namespace should isolate the variable name to it’s designated area mitigating the conflict. Just not a 100% sure unreal project will combine with that combo.
If the lib is small then you could try wrapping it’s internal functions in a namespace of it’s own
Namespacing causes its own compiler problems. I’m going to undef verify in my relevant .cpp files for now and “be careful” I don’t undef it in inappropriate places.
maybe you can try make a “middleware” to separate UE style code and the 3rd party library code,
the middleware can be 1) static global functions, or 2) a class that only including the 3rd party library header files in the *.cpp files , leaving the middleware class header files only including standard library heads.
with this way , i had integrated Qt6 libraries with UE5 project, i had compiled and link them without problem, only crashed in runtime because the QObject itself 's memory management conflict with UE5, i guess…
I think the “middleware” approach you suggest is another good solution.
It allows the .cpp file to be compiled without any unreal headers being included. I am likely to end up doing this now that I have a proof-of-concept working using #undef.
before including <cpr/cpr.h>
i could compiled and link exe file without problem , i still got crashed when running it, i think i still need to understand uboject memory recycling mechanism…