XCode uninitialized-const-reference error

When trying to build the editor on XCode Version 12.5 (12E262) on MacOS 11.2.3, I get a lot of errors like this for the fbxsdk:

.../UnrealEngine/Engine/Source/ThirdParty/FBX/2020.1.1/include/fbxsdk/scene/geometry/fbxlayer.h:464:129: variable 'v' is uninitialized when passed as a const reference argument here [-Werror,-Wuninitialized-const-reference]

This happens on the current Release branch AND a 4.25 source I have previously compiled successfully.

I was able to ignore these warning by adding -Wno-uninitialized-const-reference to BuildTool, but I am still worried this is a symptom of a bigger problem with my environment :confused:

just change line 464 in
Engine/Source/ThirdParty/FBX/2020.1.1/include/fbxsdk/scene/geometry/fbxlayer.h
to
template <class T> inline T* GetLocked(T*, ELockMode pLockMode=eReadWriteLock) {T v{}; return (T*)GetLocked(pLockMode, FbxTypeOf(v)); } will fix it.
(add a {} behind T v)

1 Like

This worked for me! Thank you.

Could you elaborate where you add it in Xcode? Thanks

To modify compile argument,in “\Engine\Source\Programs\UnrealBuildTool\Platform\XXX\XXXToolChain.cs”,in method “string GetCompileArguments_Global(CppCompileEnvironment CompileEnvironment)”,Add"Result += " -Wno-uninitialized-const-reference";".