-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Compilation Error on Clang 5.0 Upgrade #735
Comments
Which library version are you using? |
This is only happening on the develop branch-- release 2.1.1 works fine. |
Strange. I'm using clang version 5.0.0-svn312333-1~exp1 (branches/release_50) on Travis (see https://travis-ci.org/nlohmann/json/jobs/273804833 and https://travis-ci.org/nlohmann/json/jobs/273804832) without problems. |
Yup, I'm at fcba9ec. I'm using the same version of clang with the -std=c++17 flag. |
Could you please try to include |
|
Alright. Then there is something incomplete in a SFINAE. I don't want to include string_view - I just want to make sure I don't try to convert to/from it. I see if I find a way and may come back to you to test it since I cannot reproduce the error myself. |
I still cannot reproduce the issue. It seems that the SFINAE in #if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_MSC_VER) && _MSC_VER >1900 && defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
and not std::is_same<ValueType, typename std::string_view>::value
#endif needs to "know" |
You are probably seeing differences in the STL about which headers are included by other headers, or which classes are forward declared. The official position of the committee is that you MUST include all headers for classes that you use. To do otherwise is to risk compile breaks when you change compilers, or even versions. |
This would mean we need to include the required headers for |
you might be able to use SFINAE to check for the existence of it first, but then you might run into ODR issues if some TUs know about it before including json.hpp and others don't. |
In GCC 7.2.0, #if __cplusplus > 201402L
# include <string_view>
#endif In Clang 5.0.0, #include <string_view> I do not understand why @ErikPartridge 's Clang does not know about |
For me with clang++: $ clang++ --version The header is in #include <experimental/string_view> |
@xirius Thanks! Can you compile the library's tests with your clang version or do you experience the same error? |
It compiles. mkdir build -- The CXX compiler identification is Clang 6.0.0 cmake --build . Label Time Summary: Total Test time (real) = 195.22 sec |
@ErikPartridge What confuses me is that your Clang 5 relies on |
Well, clang is a compiler and |
Well, it is hard to support a compiler without C++17 headers, but with the |
Could we use the |
That may work. Then I would need to check for |
Related: #795 |
I am still not sure whether this should be fixed. I mean: why should this library include |
In principle, I agree. In practice, I'm one of the affected because the clang distribution and repos don't include libc++ and I haven't gotten around to building my own. It would be nice if I didn't have to. |
One workaround (though quite brittle), would be: // FixedJson.hpp (your header)
#include <experimental/string_view>
#include <json.hpp> Then you include this file instead of including |
see nlohmann/json#735 (comment) for details
Upgrading to Clang++-5.0 on Travis-CI Trusty is producing the following error:
Also tested on Ubuntu 16.04 Clang++-5.0 standalone without the rest of the project and still failing with the same error. g++ working fine on both systems.
The text was updated successfully, but these errors were encountered: