-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
json.hpp compilation issue with other typedefs with same name #1642
Comments
Thanks for reporting the issue! This is a reoccurring issue (e.g. #590, #606, #1530) which strangely, current CI builds haven't detected. For instance, the library are being built with GCC 4 through GCC 9 in Travis CI yet this error remains uncaught. Can you give more details on the build environment so the error can be reproduced and prevented in the future by setting up a regression build? It would be kind of you if you could reproduce the error on https://godbolt.org (you can set compiler version and build flags there). |
@nickaein i made a sample scenario where this happens https://godbolt.org/z/iHJVjA template <typename T>
class string {
};
#include <nlohmann/json.hpp>
int main() {
return 0;
} you can replace that templated class with any of the classes used by this library, and get the same error. Weirdly enough this doesn't happen when compiling for windows https://godbolt.org/z/aoAxd0 |
@edo9300: Thanks for the example! We might have to add something like this as a regression test. @kevinlul: I've just noticed you have already opened an PR for this issue. Thanks for that! You might want to add a Fixes #1642 phrase (or other keywords mentioned here) in the description of PR so that gets linked to this issue and automatically close the issue when merged. |
Fix json.hpp compilation issue with other typedefs with same name (Issue #1642)
The issue is similar to #606 and #1530: a compilation error involving
json.hpp
, with<
being interpreted as a template instead of "less than"Essentially, other typedefs with the same name as the ones used by the library are taken as reference when templating, which happens often under
using namespace
This is confirmed to happen with GCC 7.4.0 on Ubuntu and GCC 9.1.0 on macOS Mojave, compiling against the version from
apt-get
andbrew
respectively.A fix would be wrapping the comparisons with parentheses.
Also discovered by @edo9300 and @DyXel
The text was updated successfully, but these errors were encountered: