-
-
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
Add support for workarounds for non-compliant C++11 compilers #1128
Conversation
A curiosity thing, what is special about that compiler? What does it do that is unique? Why would someone use it over a modern standard compiler? |
@OvermindDL1 That's a fair question :-) It's not the compiler as such that makes it unique but the IDE i.m.o. I've used it (and its predecessors) for the past ~18 years - but I really did expect better support for C++11 when I bought this release. I also didn't like the built-in JSON support so I went for this JSON lib that I've used and liked before. |
@TedLyngmo Ah, what's special about the IDE then? I use KDevelop myself (CLion is interesting as well but it is soooooo slooooow compared to KDevelop) and find it absolutely fantastic (plus it was one of the first to use CMake as it's main build system, one of the first (if not 'the' first) to use libclang for intellisense, etc... etc...), but I'm always curious in something better. |
Well, when I first started using it, the closest competitor was Visual Studio - and that was a real pain at the time. C++ Builder haven't changed that much since then so I guess many other IDE:s have caught up. You can check it out here if you are curious to know more: C++ Builder. Anyway, there's not that much missing it it for me to be able to overcome it - and having the possibility to disable the version check (and also by being able to supply an alternative constexpr for eof()) would really help. |
That... is a very odd IDE... a custom GUI framework that doesn't match modern things, doesn't run on linux, has this weird firemonkey thing all of it (which further seems to be a proprietary thing that only runs in specific areas), among more... I'm not sure how I could even use that (linux user) first of all, second it doesn't seem to support modern standards, even the (very little) documentation I could find on cmake encourages using the very old command invocations, as well as it doesn't seem to support cmake projects at all other than building them (where if you want to edit them then you have to essentially re-write it into their ecosystem, which does not seem easily possible considering how much I have cmake generate code for me...)... o.O Plus a HolyCrapTonOfMoney, who'd pay that for just an IDE especially when its feature listings don't imply anything worth that at all?! O.o Interesting read though, didn't know such an odd ecosystem existed, that's very odd... ^.^; |
Clearly not the IDE for you :-) Oh well, any comments on the commit as such? I'd llike the input even if it's utterly rejected :) |
Well to me it looks slightly less portable, though not in any way on any architecture that someone using this library would be using, so otherwise it looks fine to me and I'd probably accept it after the usual bout of testing. It's all up to |
#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) | ||
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900 | ||
#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" | ||
#ifndef _NLOHMANN_JSON_SKIP_COMPILER_CHECK_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symbols beginning with underscore followed by a capital letter are reserved by the standard.
You should remove the first and last underscores to be compliant.
(Applies to other macros added in this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed that in the new commit.
#define _NLOHMANN_JSON_SKIP_COMPILER_CHECK_ 1 | ||
#define _NLOHMANN_JSON_FIX_CONSTEXPR_FOR_CHAR_TRAITS_EOF_ -1 | ||
|
||
namespace std { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding definitions to std
being forbidden by the standard, I guess the chances of this PR being merged are quite low...
But you know that already :p.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure did. :-) I removed the workaround file in the new commit.
Less portable is quite the opposite of what I was trying to achieve :-) Are you thinking about the actual workaround/borland.hpp file? I'm thinking of removing that file from this change and put it (without the actual defines) in a repo of its own so that anyone (with the specific platform it works on) in need of the missing cmath functions could use it in any project - and combining that file with the two defines, using this json lib will work fine. Perhaps that's a cleaner approach? |
It does look better without the workaround file. But it might open pandora's box to introduce such a customization point (the I feat it will create a precedent, and some people using another non-compliant compiler might have different workarounds for different problems. If tomorrow you find two or three more quirks inside Borland, which also require such a macro definition in upstream, that will be problematic. Furthermore, since there is no CI at the moment for this compiler, we have no way to know if future code will break those. Maybe the best solution will be to fork every release, add your patch, and make a release for |
I agree that the CONSTEXPR macro could be dangerous. I removed it so now there's only the NLOHMANN_JSON_SKIP_COMPILER_CHECK macro left. I kept this (now unconditional): It'll make patching easier and i.m.o. is easier to read when used. |
Sounds reasonable to me, I have no more issues with your PR :) |
I don't really like this extension. We support C++11-compliant compilers, and how could we justify a line like static constexpr std::char_traits<char>::int_type end_of_file = std::char_traits<char>::eof(); if We may, however, thing about guarding the compiler check with |
About the static constexpr: The way I see it, it's just another convenient constant and I don't think there's a need for an annotation like that. If the line is removed, the checks won't compile. One would have to replace all
About the compiler check: If I understand the # |
The thing with the constant About |
My IDE won't work even with the
but I'd keep that patch in my fork only (unless the above would be acceptable, which I'm not expecting). For compliant compilers, the two ( |
Then I misunderstood, sorry. But adding more macros to mitigate noncompliant compilers is even worse. Sorry, but I cannot accept this PR. |
I get that, but just to be clear: The The only macro added in the PR is |
You mean guarding the compiler check would be sufficient? |
Yes, I think I can make it work with that. |
You can now skip the compiler check by defining |
Thanks! :-) |
You're welcome. Sorry for the long discussion. |
No worries, I get it. I've been filing bug reports to the compiler vendor too but have little hope of getting an update without additional fees. Also started making adaptions to their STL implementation but it's a real mess so I don't think I'll have much luck with that. I've been able to add their missing cmath functions though, so that's working anyway, but this is very frustrating... |
Include example for Borland C++ Builder (RAD Studio)'s clang (3.3.1) based compiler (bcc32c).
I know this goes against the Contribution Guidelines and I will keep my fork rebased separately if this is unacceptable. I would nevertheless like your input please.
What I've done is to add a macro (NLOHMANN_JSON_SKIP_COMPILER_CHECK) to be able override the compiler check and one macro (NLOHMANN_JSON_FIX_CONSTEXPR_FOR_CHAR_TRAITS_EOF) to let a porter define a constexpr instead of using std::char_traits::eof(). I couldn't find a way to override the built in definition unfortunately. If you know of a way that this could be done, I'd be glad to use that way instead.
The file "include/nlohmann/detail/workarounds/borland.hpp" will not be included in the amalgamated json.hpp - so any user will have to manually include it before json.hpp. I'll happily remove this file if the other changes would be acceptable.