Plugin Build fails only on UE5.4

Hello Folks,

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

Any idea?
Thanks!
Roberto

Greetings @YobiRobert

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.

Thank you for your answer.

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 :wink:
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

Yothon.h

#pragma once

THIRD_PARTY_INCLUDES_START
#pragma push_macro("ythcheck")
#undef check
#undef ensure
#pragma warning (push)
#pragma warning (disable : 4191)
#pragma warning (disable : 4686)

#include "pybind11/pybind11.h"
#include "pybind11/embed.h"
#include "pybind11/numpy.h"

#pragma warning (pop)
#pragma pop_macro("ythcheck")
THIRD_PARTY_INCLUDES_END

#include "Modules/ModuleManager.h"
#include "Misc/Paths.h"
#include "Structures.h"

Yothon.cpp

#include "Yothon.h"
#define LOCTEXT_NAMESPACE "FYothonModule"
DEFINE_LOG_CATEGORY(YothonLog);

YothonBPLibrary.cpp

#include "YothonBPLibrary.h"
#include "Misc/Paths.h"

Hope I didnā€™t forgot something, Iā€™ll double check again later,
Thank you so much!

Hmmmā€¦ I think I have to address the elephant in the room:

THIRD_PARTY_INCLUDES_START
#pragma push_macro("ythcheck")
#undef check
#undef ensure
#pragma warning (push)
#pragma warning (disable : 4191)
#pragma warning (disable : 4686)

#include "pybind11/pybind11.h"
#include "pybind11/embed.h"
#include "pybind11/numpy.h"

#pragma warning (pop)
#pragma pop_macro("ythcheck")
THIRD_PARTY_INCLUDES_END

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:

  1. Are there any more warning suppression or macros like #undef, #pragma pop_macro or #pragma warning in those files?
  2. 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.
  3. 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ā€¦
  4. ā€¦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.

Hope, this will help you!

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.

The files, where said macros are stored on Windows, are these:

And the only difference between 5.3 and 5.4 is following addition:

#ifndef PRAGMA_DISABLE_UNREACHABLE_CODE_WARNINGS
	#define PRAGMA_DISABLE_UNREACHABLE_CODE_WARNINGS \
		__pragma (warning(push)) \
		__pragma (warning(disable: 4702)) /* unreachable code */
#endif // PRAGMA_DISABLE_UNREACHABLE_CODE_WARNINGS

#ifndef PRAGMA_RESTORE_UNREACHABLE_CODE_WARNINGS
	#define PRAGMA_RESTORE_UNREACHABLE_CODE_WARNINGS \
		__pragma (warning(pop))
#endif // PRAGMA_RESTORE_UNREACHABLE_CODE_WARNINGS

which narrows down to suppressing C4702

This does not seem like something that should cause any compilation issues.

Are you sure this ainā€™t a problem with your VS22/MSVC setup? @YobiRobert

1 Like

I was actually wondering the same thing in regards to the VS22 @dzemzmcdonalda.

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)

void FAvaCameraZoomController::CenterOnBox(const FBox& InBoundingBox, const FTransform& InBoxTransform)
{
	// TODO @Update
	return;

	TSharedPtr<IAvaViewportClient> AvaViewportClient = AvaViewportClientWeak.Pin();

       /*  snip */
}

It seems @dzemzmcdonalda was right.

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.

2 Likes

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.

3 Likes