查找预编译文件时出现意外的文件结尾 header
Unexpected end of file while looking for precompiled header
我一直在尝试将我的代码组织成 sub-folders,并且自从我上次提交以来,我一直很小心,不做任何额外的事情。我目前收到一堆 C1010
错误说:
unexpected end of file while looking for precompiled header. Did you forget to add #include "pch.h" to your source?
每个文件都有预编译 header 文件的适当相对包含路径。如果我尝试“de-relativize”预编译的 header 包含,然后 Intellisense 开始抛出错误..
我怀疑我的 cmake 代码可能有问题..
特别是这部分:...
if (MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Minecraft)
set_target_properties(Minecraft PROPERTIES COMPILE_FLAGS "/Yupch.h")
set_source_files_properties("src/pch.cpp" PROPERTIES COMPILE_FLAGS "/Ycpch.h")
target_compile_options(Minecraft PRIVATE "/W4" "/MP" "/std:c++17")
endif()
所以替换下面的代码...
if (MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Minecraft)
set_target_properties(Minecraft PROPERTIES COMPILE_FLAGS "/Yupch.h")
set_source_files_properties("src/pch.cpp" PROPERTIES COMPILE_FLAGS "/Ycpch.h")
target_compile_options(Minecraft PRIVATE "/W4" "/MP" "/std:c++17")
endif()
和
if (MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Minecraft)
target_precompile_headers(Minecraft PRIVATE "src/pch.h")
target_compile_options(Minecraft PRIVATE "/W4" "/MP" "/std:c++17")
endif()
问题已解决!
我一直在尝试将我的代码组织成 sub-folders,并且自从我上次提交以来,我一直很小心,不做任何额外的事情。我目前收到一堆 C1010
错误说:
unexpected end of file while looking for precompiled header. Did you forget to add #include "pch.h" to your source?
每个文件都有预编译 header 文件的适当相对包含路径。如果我尝试“de-relativize”预编译的 header 包含,然后 Intellisense 开始抛出错误..
我怀疑我的 cmake 代码可能有问题.. 特别是这部分:...
if (MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Minecraft)
set_target_properties(Minecraft PROPERTIES COMPILE_FLAGS "/Yupch.h")
set_source_files_properties("src/pch.cpp" PROPERTIES COMPILE_FLAGS "/Ycpch.h")
target_compile_options(Minecraft PRIVATE "/W4" "/MP" "/std:c++17")
endif()
所以替换下面的代码...
if (MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Minecraft)
set_target_properties(Minecraft PROPERTIES COMPILE_FLAGS "/Yupch.h")
set_source_files_properties("src/pch.cpp" PROPERTIES COMPILE_FLAGS "/Ycpch.h")
target_compile_options(Minecraft PRIVATE "/W4" "/MP" "/std:c++17")
endif()
和
if (MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Minecraft)
target_precompile_headers(Minecraft PRIVATE "src/pch.h")
target_compile_options(Minecraft PRIVATE "/W4" "/MP" "/std:c++17")
endif()
问题已解决!