Compilation error with MSVC: "fatal error C1004: unexpected end-of-file found"
fenghou1st opened this issue · comments
fenghou commented
A simple project with cmake, created by CLion (version 2022.1.3):
CMakeLists.txt
cmake_minimum_required(VERSION 3.22)
project(test20)
set(CMAKE_CXX_STANDARD 20)
include_directories(C:/Libraries/zpp_bits)
add_executable(test20 main.cpp)
main.cpp
#include <zpp_bits.h>
struct person
{
std::string name;
int age{};
};
int main() {
auto [data, in, out] = zpp::bits::data_in_out();
out(person{"Person1", 25}, person{"Person2", 35});
person p1, p2;
in(p1, p2);
return 0;
}
Building output:
C:\PROGRA~2\MICROS~1\2019\PROFES~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe /nologo /TP -IC:\Libraries\zpp_bits /DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -MDd -std:c++20 /showIncludes /FoCMakeFiles\test20.dir\main.cpp.obj /FdCMakeFiles\test20.dir\ /FS -c D:\cpp\test20\main.cpp
D:\cpp\test20\main.cpp(12): warning C4834: discarding return value of function with 'nodiscard' attribute
D:\cpp\test20\main.cpp(16): warning C4834: discarding return value of function with 'nodiscard' attribute
C:\Libraries\zpp_bits\zpp_bits.h(865): fatal error C1004: unexpected end-of-file found
Looks like the problem is caused by MSCV (version 16.0), right?
How can I avoid this error?
fenghou commented
After upgrading to Visual Studio 2022, the problem disappeared. 👏
Eyal Z commented
Glad this was resolved, make sure to do not discard any error codes where this warning appears - look in the readme guide for error handling approaches.
fenghou commented
Glad this was resolved, make sure to do not discard any error codes where this warning appears - look in the readme guide for error handling approaches.
Thanks, I will do as the guide says. 👌