You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Multiple declarations" error when using types defined with typedef #611
I have types in my code that use typedef statements to specialize some of the standard container types. I get a "Multiple declarations" error for to_json when I attempt to convert one of these to json so I can output them into a results file.
but I get an extremely verbose error telling me I have multiple declarations of the to_json instance. It's similar to the error I would get when using the implicit conversion of n.state = j.at("state") without using get<vector<float>>().
I also tried explicitly copying the values to no avail.
The reason for inline is that you're telling the compiler that you expect this definition to appear in multiple "translation units" and that it should eliminate all the extra definitions. http://en.cppreference.com/w/cpp/language/inline
Activity
nlohmann commentedon Jun 7, 2017
I cannot reproduce the error. This code works (Clang):
Output:
gregmarr commentedon Jun 7, 2017
Did you put the
to_jsonimplementation in a header file and not use theinlinekeyword?gregmarr commentedon Jun 9, 2017
The reason for
inlineis that you're telling the compiler that you expect this definition to appear in multiple "translation units" and that it should eliminate all the extra definitions.http://en.cppreference.com/w/cpp/language/inline