UE4SS-RE / RE-UE4SS

Injectable LUA scripting system, SDK generator, live property editor and other dumping utilities for UE4/5 games
http://docs.ue4ss.com/
MIT License
1.39k stars 187 forks source link

Compile error with PolyHook (asmjit) + Unreal/Core/Misc/AssertionMacros.hpp #546

Open UE4SS opened 6 months ago

UE4SS commented 6 months ago

I'm making this issue just to make people aware of the problem, hopefully it will be helpful if anyone runs into the same problem in the future. I don't think we currently need to address this problem, it's a very low priority since everything works if you are careful where you include PolyHook.

If you include PolyHook after any Unreal files (which also includes AssertionMacros.hpp) then it will fail to compile because of the ensure macro that AssertionMacros.hpp defines. This is because asmjit (which PolyHook uses) has a function with the same name and the macro will override that which means the macro contents will be used as the function name instead which ends up as invalid code and a compile error. The easiest way to solve this is to include PolyHook before anything from Unreal.

The full error:

Intermediates\.packages\p\polyhook_2\latest\694b58f2ef38459bb962315096367668\include\asmjit\core\../core/zone.h(196): error C2059: syntax error: '!'
Intermediates\.packages\p\polyhook_2\latest\694b58f2ef38459bb962315096367668\include\asmjit\core\../core/zone.h(196): error C2334: unexpected token(s) preceding '{'; skipping apparent function body   
Intermediates\.packages\p\polyhook_2\latest\694b58f2ef38459bb962315096367668\include\asmjit\core\../core/zone.h(196): error C2059: syntax error: ')'
Intermediates\.packages\p\polyhook_2\latest\694b58f2ef38459bb962315096367668\include\asmjit\core\../core/zone.h(196): error C2334: unexpected token(s) preceding '{'; skipping apparent function body