我在创建新的c++类时遇到了一个问题。例如,did是一个播放器控制器,它可以编译,但是当它在Visual Studio中打开时,它会说有太多的错误使IntelliSense无法正常工作。我的虚幻引擎版本是4.25,visual studio 2019版本是16.6.2
然后它在错误列表中变得疯狂,有15390个错误
Severity Code Description Project File Line Suppression State
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatformTLS.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\PlatformTLS.h 8
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatformTime.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\PlatformTime.h 7
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatformString.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\PlatformString.h 6
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatformProperties.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\PlatformProperties.h 11
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatformProcess.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\PlatformProcess.h 7
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatformMisc.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\PlatformMisc.h 7
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatformMemory.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\PlatformMemory.h 7
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatformMath.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\PlatformMath.h 7
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatformAtomics.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\PlatformAtomics.h 8
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatformCompilerSetup.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\Platform.h 1024
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatform.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\Platform.h 135
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatformCompilerPreSetup.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\Platform.h 81
Error (active) E1696 cannot open source file "UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMCriticalSection.h" TestingCode C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\HAL\CriticalSection.h 7 发布于 2020-06-22 05:36:35
发布于 2020-06-22 22:15:46
我几乎每天都有这样的东西。我的建议是,当涉及到错误时,不要依赖IntelliSense,并将Visual Studio中的" errors“窗口更改为只显示"Build only”错误。
当你构建的时候,你只会得到真正的错误,而这些错误实际上正在扰乱你的构建。因为UnrealHeaderTool实际上在后台创建了很多代码,所以在创建新类或重构方法时,有些东西是不可用的。
最佳实践似乎是只依赖于MSBuild提供的功能,而不是等待IntelliSense赶上。修复编译器中的“找不到此文件”或“未定义类型”之类的错误应该比尝试告诉IntelliSense理解存在不是预处理器宏而是UHT宏的宏容易得多。
如果你仅仅停留在构建错误上,问题会在某一时刻消失。至少对我来说是这样的。
还要注意,Unreal使用的unity构建可能会破坏您甚至没有处理的文件,因为当构建工具合并上次构建中的文件时,您忘记了已经存在的包含。
https://stackoverflow.com/questions/62493213
复制相似问题