yalantinglibs: struct_pack is not compatible with vs2017 c++17

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

i get an error when compiling with vs2017 c++17

Reproduction way

  • test code
struct MyStruct {
    unsigned int test{};
};

int main(int argc, char* argv[]) {
    MyStruct test{};
    auto     out1 = struct_pack::serialize(test);
    auto     out2 = struct_pack::deserialize<MyStruct>(out1);
    return 0;
}

  • compiler configuration

    • Visual Studio 2017 (v141) image

    • ISO C++17 Standard (/std:c++17) image

  • first time error

    1>------ Build started: Project: ConsoleApplication1, Configuration: Release x64 ------
    1>ConsoleApplication1.cpp
    1>d:\\superthirdparty\yalantinglibs\include\ylt\struct_pack\marco.h(34): warning C4067: unexpected tokens following preprocessor directive - expected a newline
    1>d:\\superthirdparty\yalantinglibs\include\ylt\struct_pack\marco.h(42): warning C4067: unexpected tokens following preprocessor directive - expected a newline
    1>d:\\superthirdparty\yalantinglibs\include\ylt\struct_pack\endian_wrapper.hpp(17): fatal error C1083: Cannot open include file: 'bit': No such file or directory
    1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.
    
  • maybe vs2017 c++17 didn’t implement it and then I used a higher version of the bit header file and still got the error

    1>------ Build started: Project: ConsoleApplication1, Configuration: Release x64 ------
    1>ConsoleApplication1.cpp
    1>d:\\yalantinglibs\include\ylt\struct_pack\marco.h(34): warning C4067: unexpected tokens following preprocessor directive - expected a newline
    1>d:\\yalantinglibs\include\ylt\struct_pack\marco.h(42): warning C4067: unexpected tokens following preprocessor directive - expected a newline
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(118): error C2825: 'T': must be a class or namespace when followed by '::'
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(364): note: see reference to class template instantiation 'struct_pack::detail::get_array_element<unsigned int>' being compiled
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(346): note: see reference to function template instantiation 'bool struct_pack::detail::check_if_compatible_element_exist_impl_helper<18446744073709551615,unsigned int,>(void)' being compiled
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(487): note: see reference to function template instantiation 'bool struct_pack::detail::check_if_compatible_element_exist_impl<18446744073709551615,U,,0>(std::integer_sequence<unsigned __int64,0>)' being compiled
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(492): note: see reference to function template instantiation 'bool struct_pack::detail::check_if_compatible_element_exist<T,18446744073709551615>(void)' being compiled
    1>        with
    1>        [
    1>            T=std::tuple<unsigned int>
    1>        ]
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(671): note: see reference to variable template 'const bool exist_compatible_member<MyStruct,-1>' being compiled
    1>d:\\yalantinglibs\include\ylt\struct_pack\calculate_size.hpp(405): note: see reference to class template instantiation 'struct_pack::detail::serialize_static_config<Type>' being compiled
    1>d:\\yalantinglibs\include\ylt\struct_pack.hpp(144): note: see reference to function template instantiation 'struct_pack::serialize_buffer_size struct_pack::detail::get_serialize_runtime_info<0,MyStruct>(const MyStruct &)' being compiled
    1>d:\\yalantinglibs\include\ylt\struct_pack.hpp(205): note: see reference to function template instantiation 'void struct_pack::serialize_to<0,Buffer,MyStruct>(Writer &,const MyStruct &)' being compiled
    1>        with
    1>        [
    1>            Buffer=std::vector<char,std::allocator<char>>,
    1>            Writer=std::vector<char,std::allocator<char>>
    1>        ]
    1>d:\vs\source\repos\consoleapplication1\consoleapplication1\consoleapplication1.cpp(18): note: see reference to function template instantiation 'Buffer struct_pack::serialize<std::vector<char,std::allocator<char>>,MyStruct>(const MyStruct &)' being compiled
    1>        with
    1>        [
    1>            Buffer=std::vector<char,std::allocator<char>>
    1>        ]
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(118): error C2510: 'T': left of '::' must be a class/struct/union
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(118): error C2061: syntax error: identifier 'value_type'
    1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2027: use of undefined type 'std::variant_size<_Ty>'
    1>        with
    1>        [
    1>            _Ty=unsigned int
    1>        ]
    1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: see declaration of 'std::variant_size<_Ty>'
    1>        with
    1>        [
    1>            _Ty=unsigned int
    1>        ]
    1>d:\\yalantinglibs\include\ylt\struct_pack\type_calculate.hpp(429): note: see reference to variable template 'const size_t variant_size_v<unsigned int>' being compiled
    1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2065: 'value': undeclared identifier
    1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): error C2131: expression did not evaluate to a constant
    1>c:\program files\microsoft visual studio\2022\enterprise\vc\tools\msvc\14.16.27023\include\variant(390): note: a non-constant (sub-)expression was encountered
    1>Done building project "ConsoleApplication1.vcxproj" -- FAILED.
    

Anything else

  • the visual studio installer allows you to quickly install the vs2017 c++ toolchain.

image

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

About this issue

  • Original URL
  • State: open
  • Created 7 months ago
  • Comments: 17

Most upvoted comments

I’m afraid it’s no a simple problem. Maybe I will fix it later when I have time.

Well, I think it’s possible to fix the problem, I check the cpprefence and it seems that the highest version of VS2017 support almost all c++17 feature.