Skip to content

Incompatible with C++20 modules in MSVCΒ #3970

Open
@andylizf

Description

@andylizf

Description

Importing a module file using the lib will cause a compilation error.

Reproduction steps

Codes below.

Expected vs. actual results

To compile successfully.

Minimal code example

network.ixx:

module;
#include <nlohmann/json.hpp>
#include <string>
export module network;
using nlohmann::json;
export struct message {
  message(std::string str) { json doc = json::parse(str); }
};

main.cpp:

import network;
int main() { message msg(R"({"hello": "world"})"); }

Error messages

nlohmann\json.hpp(117): error C2039: 'json_sax_dom_callback_parser': is not a member of 'nlohmann::json_abi_v3_11_2::detail'
nlohmann\detail\output\serializer.hpp(35): note: see declaration of 'nlohmann::json_abi_v3_11_2::detail'
main.cpp(3): note: see reference to class template instantiation 'nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char>>,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>>' being compiled
nlohmann\byte_container_with_subtype.hpp(101): warning C4820: 'nlohmann::json_abi_v3_11_2::byte_container_with_subtype<BinaryType>': '7' bytes padding added after data member 'nlohmann::json_abi_v3_11_2::byte_container_with_subtype<BinaryType>::m_has_subtype'
        with
        [
            BinaryType=std::vector<uint8_t,std::allocator<uint8_t>>
        ]
        [            BinaryType=std::vector<uint8_t,std::allocator<uint8_t>>
        ]
nlohmann\json.hpp(4187): warning C4820: 'nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char>>,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>>': '7' bytes padding added after data member 'nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::basic_string<char,std::char_traits<char>,std::allocator<char>>,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>>::m_type

Compiler and operating system

Visual Studio 17 2022 MSVC 19.36.32323; Windows-10.0.22624

Library version

3.11.2

Validation

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions