marzer / tomlplusplus

Header-only TOML config file parser and serializer for C++17.
https://marzer.github.io/tomlplusplus/
MIT License
1.58k stars 152 forks source link

array::insert_at defined with TOML_API rather than TOML_EXTERNAL_LINKAGE #136

Closed Azarael closed 2 years ago

Azarael commented 2 years ago

Environment

toml++ version and/or commit hash:
v3 - commit hash 5c5abfd

Compiler:
MSVC 2022

C++ standard mode:
latest

Target arch:
x64

Library configuration overrides:
None.

Relevant compilation flags:
None.

Describe the bug

The definition of array::insert_at in array.inl is preceded by TOML_API rather than TOML_EXTERNAL_LINKAGE (inline) as the other functions in the file are. This is causing ODR violations in my project.

marzer commented 2 years ago

Good find, thanks for the report! Fixed in the master branch.

marzer commented 2 years ago

@Azarael It occurred to me that the reason you experienced this and I hadn't was the combination of TOML_HEADER_ONLY and including the library in multiple translation units. FYI you can improve your compile times by disabling TOML_HEADER_ONLY and defining TOML_IMPLEMENTATION in a single TU (ref: Speeding up compilation)

Having said that, I'm thankful you did experience it, so I could fix it! 😄