I am having a problem building my plugin. It builds fine for v.5.1-2-3, but fails with 5.4. I tried to add/change some include files just in case I was missing something, with no luck.
Here are the errors
VS2022 (17.9.6) + UE5.4.1 )
[1/4] Compile [x64] Yothon.cpp
D:\Software\VS2022\VC\Tools\MSVC\14.38.33130\INCLUDE\sal.h(2361): error C2144: syntax error: 'int' should be preceded by ';'
D:\UE5\UE_5.4\Engine\Source\Runtime\Core\Public\GenericPlatform\GenericPlatform.h(9): error C2143: syntax error: missing ';' before '<L_GRAMMAR_template_head_l>'
D:\UE5\UE_5.4\Engine\Source\Runtime\Core\Public\GenericPlatform\GenericPlatform.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Public\Yothon.h(45): error C2504: 'FRunnable': base class undefined
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Public\Yothon.h(60): error C3668: 'FPythonRunnable::~FPythonRunnable': method with override specifier 'override' did not override any base class methods
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Public\Yothon.h(62): error C3668: 'FPythonRunnable::Init': method with override specifier 'override' did not override any base class methods
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Public\Yothon.h(63): error C3668: 'FPythonRunnable::Run': method with override specifier 'override' did not override any base class methods
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Public\Yothon.h(64): error C3668: 'FPythonRunnable::Exit': method with override specifier 'override' did not override any base class methods
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Public\Yothon.h(65): error C3668: 'FPythonRunnable::Stop': method with override specifier 'override' did not override any base class methods
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Private\Yothon.cpp(42): error C2027: use of undefined type 'FRunnableThread'
D:\UE5\UE_5.4\Engine\Source\Runtime\Core\Public\Windows\WindowsPlatformProcess.h(10): note: see declaration of 'FRunnableThread'
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Private\Yothon.cpp(42): error C3861: 'Create': identifier not found
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Private\Yothon.cpp(353): error C2027: use of undefined type 'FTexture2DMipMap'
D:\UE5\UE_5.4\Engine\Source\Runtime\Engine\Classes\Engine\Texture2D.h(20): note: see declaration of 'FTexture2DMipMap'
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Private\Yothon.cpp(357): error C3536: 'blob': cannot be used before it is initialized
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Private\Yothon.cpp(357): error C2664: 'void *FMemory::Memcpy(void *,const void *,SIZE_T)': cannot convert argument 1 from 'int' to 'void *'
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Private\Yothon.cpp(357): note: Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or parenthesized function-style cast
D:\UE5\UE_5.4\Engine\Source\Runtime\Core\Public\HAL\UnrealMemory.h(160): note: see declaration of 'FMemory::Memcpy'
D:\UE5\UE_5.4\Engine\Source\Runtime\Core\Public\HAL\UnrealMemory.h(166): note: could be 'void FMemory::Memcpy(T &,const T &)'
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Private\Yothon.cpp(357): note: 'void FMemory::Memcpy(T &,const T &)': expects 2 arguments - 3 provided
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Private\Yothon.cpp(357): note: while trying to match the argument list '(int, void *, Py_ssize_t)'
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Private\Yothon.cpp(360): error C2027: use of undefined type 'FTexture2DMipMap'
D:\UE5\UE_5.4\Engine\Source\Runtime\Engine\Classes\Engine\Texture2D.h(20): note: see declaration of 'FTexture2DMipMap'
[2/4] Compile [x64] YothonBPLibrary.cpp
D:\Software\VS2022\VC\Tools\MSVC\14.38.33130\INCLUDE\sal.h(2361): error C2144: syntax error: 'int' should be preceded by ';'
D:\UE5\UE_5.4\Engine\Source\Runtime\Core\Public\GenericPlatform\GenericPlatform.h(9): error C2143: syntax error: missing ';' before '<L_GRAMMAR_template_head_l>'
D:\UE5\UE_5.4\Engine\Source\Runtime\Core\Public\GenericPlatform\GenericPlatform.h(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Public\Yothon.h(45): error C2504: 'FRunnable': base class undefined
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Public\Yothon.h(60): error C3668: 'FPythonRunnable::~FPythonRunnable': method with override specifier 'override' did not override any base class methods
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Public\Yothon.h(62): error C3668: 'FPythonRunnable::Init': method with override specifier 'override' did not override any base class methods
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Public\Yothon.h(63): error C3668: 'FPythonRunnable::Run': method with override specifier 'override' did not override any base class methods
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Public\Yothon.h(64): error C3668: 'FPythonRunnable::Exit': method with override specifier 'override' did not override any base class methods
D:\YobiMinds\Progetti\Yothon\EpicMarketplace\Builds\Version5.4\HostProject\Plugins\yothon\Source\Yothon\Public\Yothon.h(65): error C3668: 'FPythonRunnable::Stop': method with override specifier 'override' did not override any base class methods
Welcome back to the Unreal Engine Community Forum! Iām not 100% sure if this is the problem. But, the first line of error you posted āerror C2144: syntax error: āintā should be preceded by ā;āā is something Iād start with. I had this same error once and couldnāt compile because I didnāt add the ā;ā to my header file. Iām not sure thatās the same scenario here. But, Iād start with that error first.
that sal.h is an include file in VS2022 distribution, not really something Iād like to edit. Moreover, the same code compiles fine under UE5.3 with the same VS2022 version, so I deduce is something related to UE5.4, but at the moment the listed errors are not helping me out.
Could you post the code from Yothon.h, Yothon.cpp or YothonBPLibrary.cpp ?
Or at least the very top of those files where the includes are?
I highly doubt this issue has anything to do with MSVC standard libraries nor Engine source.
There is most likely something wrong with your code or setup.
Being an issue with my code was my first guess
What confuses me it is that it builds ok with 5.3, 5.2 and 5.1 - but yes, could be something wrong in my code, that falls into a ātrapā with the new 5.4.
Anyhow, here are the headers
Iāve never done any 3rd-party includes so Iām not really sure whatās going on.
I see you tried to suppress some warnings here, right? This is pretty dangerous and very much compiler dependent. I suspect it can be a source of your issues. The most concerning is probably #undef check and #undef ensure since these macros are used everywhere across Unreal.
Unless the issue is somewhere deeper in those files, the problem is probably in said code chunk in Yothon.h.
So, sadly, I donāt know the solution, but I have some ideas and questions that may help you trouble-shot this further:
Are there any more warning suppression or macros like #undef, #pragma pop_macro or #pragma warning in those files?
Try to comment out all warning suppression and compile it. This will NOT fix it but may give you more meaningful errors about why compilation is failing.
You said youāre using VS2022 with MSVC 17.9.6 but per documentation, one should use MSVC 17.8 for UE5.4. Also EPIC did some changes with MSVC support as they stopped supporting VS2019 in UE5.4. Thatās said you may have a wrong Visual Studio setupā¦
ā¦and for some reason the very first compilation error says that engine is trying to use library from MSVC 14.38.33130. This yet again may indicate that there is something wrong with your Visual Studio setup. If nothing that I mentioned help, try reinstalling Visual Studio. Make sure to do a clean installation and follow the documentation during setup.
Ok, I narrowed down the problem. The THIRD_PARTY_INCLUDES (_START / _END) macros seem to create the error. If I simply comment them out, the compilation is successful (with some warnings).
To better understand, I am now trying to find out what are the differences between 5.3 and 5.4.
Not being a UE dev, any help will be greatly appreciated.
Getting many of 4702s which I suspect is breaking the BatchFiles\Build.bat step. Hereās an example of a TODO thatās triggering an error: (commit: c8304451, release: 5.4.2)
I was also receiving a bunch of these errors, including for the same class listed in the post above, and for me the issue turned out to be that I did indeed have the wrong version of MSVC installed.
From Visual Studio Installer, under Individual Components, ensure you have MSVC v14.38-17.8 installed. I only had the latest version installed and it seems to have been the cause of these issues.
Also I was able to keep the latest version and then install v14.38-17.8 and when having both I was able to build properly.
Not sure if what youāre are getting is relevent to the OPās problem, but if itās C4702 in MSVC or -Wunreachable-code in clang due to some internal code change mixed with compiler flags changes, then you can try suppressing these warnings. Those arenāt any critical issues, itās just unused code which compiler will optimize away . The fact that these fail compilation is because Unreal uses /WX flag in MSVC and -Werror in clang which turn any warnings into errors.
This is generally a common problem when switching between Engine versions.
Each major UE release is developed against specific implementation of libC, C++STL, Win32API and other important libraries which come bundled with MSVC, and the toolchain also may change a bit. Mixing engine versions with wrong MSVC installations will usually produce all kinds of strange warnings.
This just a hustle of using Windows (haha). On MacOSX and Linux source code comes with itās own LLVM-based toolchain already installed. Sadly, on Windows this is simply impossible as MSVC is Microsoftās property.
I also had the problem building the Engine (5.4.3) due to the unreachable-code warning treated as error (I guess it can also happen when building ThirdParty Plugins). For some reason the __pragma statements in Engine/Source/Runtime/Core/Public/MSVC/MSVCPlatformCompilerPreSetup.h were not taken into account. I solved my problem by editing Engine/Source/Programs/UnrealBuildTool/Platform/Windows/VCToolChain.cs in the following way:
Arguments.Add("/wd4702"); // <-- Add this on line 1006
This effectively passes a flag to the compiler flag that allows segments of unreachable-code (e.g. treats them as warning or skips them instead of treating them as errors).
This is quite hacky and there definitely is a better solution but I did not have the time to investigate further.