getml / reflect-cpp

A C++20 library for fast serialization, deserialization and validation using reflection. Supports JSON, BSON, CBOR, flexbuffers, msgpack, TOML, XML, YAML / msgpack.org[C++20]
https://getml.github.io/reflect-cpp/
MIT License
783 stars 63 forks source link

import VS 2022 compiler error #97

Open laurentcau opened 2 months ago

laurentcau commented 2 months ago

Hi,

using

import <rfl/json.hpp>;
import <rfl.hpp>;

Generates warnings and compiler internal error (Not sure they are related.) with VS 2022 17.9.2.

1>E:\build\unreal\external\include\ctre.hpp(274,16): warning C5260: the constant variable 'ctll::construct_from_pointer' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit
1>(compiling source file '../../external/include/rfl.hpp')
1>E:\build\unreal\external\include\ctre.hpp(274,16): warning C5260: the constant variable 'ctll::construct_from_pointer' has internal linkage in an included header file context, but external linkage in imported header unit context; consider declaring it 'inline' as well if it will be shared across translation units, or 'static' to express intent to use it local to this translation unit
1>(compiling source file '../../external/include/rfl/json.hpp')
1>E:\build\unreal\external\include\rfl\json.hpp(15,1): error C1001: Internal compiler error.
1>E:\build\unreal\external\include\rfl\json.hpp(15,1): error C1001: (compiler file 'D:\a\_work\1\s\src\vctools\Compiler\CxxFE\sl\p1\c\module\writer.cpp', line 6669)
1>E:\build\unreal\external\include\rfl\json.hpp(15,1): error C1001:  To work around this problem, try simplifying or changing the program near the locations listed above.
1>E:\build\unreal\external\include\rfl\json.hpp(15,1): error C1001: If possible please provide a repro here: https://developercommunity.visualstudio.com 
1>E:\build\unreal\external\include\rfl\json.hpp(15,1): error C1001: Please choose the Technical Support command on the Visual C++ 
1>E:\build\unreal\external\include\rfl\json.hpp(15,1): error C1001:  Help menu, or open the Technical Support help file for more information
laurentcau commented 2 months ago

Reported to Microsoft team: https://developercommunity.visualstudio.com/t/using-c-import-makes-the-compler-crash/10654127

liuzicheng1987 commented 2 months ago

This one is tricky. I don't really know what to do about it. It appears it has something to do with the ctre library, which is a dependency we use.

Apparently it doesn't like this line in ctre.hpp:

constexpr auto construct_from_pointer = construct_from_pointer_t{};

But I personally can't see anything wrong with it. And it's been working fine so far...