mayah / tinytoml

A header only C++11 library for parsing TOML
BSD 2-Clause "Simplified" License
167 stars 31 forks source link

Inline internal::type_name<> templates. #8

Closed peria closed 8 years ago

peria commented 8 years ago

This template and its specializations can be instantiated in each object file. In such a case, we cannot link multiple object files which use toml.h. Without inline, it depends on compilers and its optimization settings whether this templates are in-line expanded.

To help compilers to expand it and to avoid link conflicts, this CL adds inline attributes to the template.

mayah commented 8 years ago

Oops. Thanks for the quick fix!

peria commented 8 years ago

It is difficult to make a test to verify this situation in a reliable way, but you can check it as follows.

  1. Add a file empty.cc which just includes toml.h under src/
  2. Compile it with src/parse_stdin.cc. I confirmed it with VC++14 (2015)
> cl src/parse_stdin.cc src/empty.cc /Iinclude
mayah commented 8 years ago

I'll write a link test to prevent this.