Open
Conversation
…multiple translation units
emilk
requested changes
Sep 22, 2019
Owner
emilk
left a comment
There was a problem hiding this comment.
I think this is an excellent idea, but we no longer need CONFIGURU_IMPLEMENTATION. In fact, its use is indicative of a user error - someone updated Configuru and did not realize they now need to make use of configuru.cpp.
| #include <configuru.cpp> | ||
|
|
||
| For more info, please see README.md (at www.github.com/emilk/configuru). | ||
| */ |
Owner
There was a problem hiding this comment.
Here it would be good with this check:
#if defined(CONFIGURU_IMPLEMENTATION)
#error "You are defining CONFIGURU_IMPLEMENTATION. This is for older versions of Configuru. You should now instead include configuru.cpp (or build it and link with it)"
#endif
| Then, in only one .cpp file: | ||
|
|
||
| ``` C++ | ||
| #define CONFIGURU_IMPLEMENTATION 1 |
Owner
There was a problem hiding this comment.
We do not need CONFIGURU_IMPLEMENTATION anymore!
Author
|
I will make these changes. I'm a little swamped at the moment, so it probably won't be until next week. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses issue #9
When Configuru is included in separate translation units, it can result in LNK2005 errors on MSVC.
GCC seems to handle this fine, but it is still a violation of the One Definition Rule, where it appears Configuru is still built into multiple translation units.
This commit is similar to that done on Loguru two years ago.
I have shown this works successfully in two different projects that utilize Configuru in separate units. One uses two different configuration files. The other uses Configuru for a config file and then some simple JSON formatting for a web API.
I don't use Boost and really didn't feel like messing with getting that to work. So I was able to build the test suite (using std::experimental::filesystem instead of boost::filesystem) and confirm the tests still all pass. I've not included this in the merge request, but if interested the code that works with std::experimental::filesystem can be seen on the separate_into_hpp_and_cpp branch of psyklopz/Configuru.