-
Notifications
You must be signed in to change notification settings - Fork 24
fix use of __GNUC__ for gcc detection #211
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
Conversation
|
Oh huh, I guess |
|
Thanks for looking into this, and sorry it has taken me so long to take up the issue. I'm not convinced this is a problem yet. A grep for GNUC in the boost tree yields over a thousand lines, whereas a grep for BOOST_GCC yields only about 350. It looks like if this is a problem, it's already rife within Boost. More importantly, looking at the Boost config headers, I see this in select_compiler_config.hpp: # elif defined(__GNUC__) && !defined(__ibmxl__)
// GNU C++:
# define BOOST_COMPILER_CONFIG "boost/config/compiler/gcc.hpp"and this in boost/config/compiler/gcc.hpp: #define BOOST_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if !defined(__CUDACC__)
#define BOOST_GCC BOOST_GCC_VERSION
#endifIOW, BOOST_GCC is defined strictly in terms of GNUC*, with no attention paid at all to Clang. Am I missing something? |
|
Oh, and as for the broken tests, Parser is meant to be usable standalone. If this is a problem that needs fixing, it will involve duplicating a small part of Boost.Config probably. |
no worries
It's likely that a bunch of those places are erroneous, but I haven't looked into this at boost scale. I only discovered this in Parser by chance when I noticed that I didn't spot any bug caused by this either, since you provided workarounds for older gcc versions in all cases.
Yes. This header only gets included if Boost.Config determines that this is not clang, see Particularly #elif defined __clang__ && !defined(__ibmxl__) && !defined(__CODEGEARC__)
// Clang C++ emulates GCC, so it has to appear early.
# define BOOST_COMPILER_CONFIG "boost/config/compiler/clang.hpp"
...
# elif defined(__GNUC__) && !defined(__ibmxl__)
// GNU C++:
# define BOOST_COMPILER_CONFIG "boost/config/compiler/gcc.hpp"
since we only need to disambiguate clang and gcc (no one else defines |
… real (non-Clang-emulated) GCC builds; replace relevant uses of the __GNUC__ macro with BOOST_PARSER_GCC. See discussion in PR #211.
… real (non-Clang-emulated) GCC builds; replace relevant uses of the __GNUC__ macro with BOOST_PARSER_GCC. See discussion in PR #211.
|
Thanks for the explanation. I get it now. The fix I want to use is very different, because I uncovered a couple of other changes I wanted to make when I made the main change (GNUC -> BOOST_PARSER_GCC). So this PR is superseded by PR #214. |
… real (non-Clang-emulated) GCC builds; replace relevant uses of the __GNUC__ macro with BOOST_PARSER_GCC. See discussion in PR #211.
__GNUC__is not useable to detect presence of gcc, nor has it ever been. It represents the current version of the GNU C language extensions, as implemented by gcc of the respective major version.Accordingly, clang defines
__GNUC__to 5, which breaks a lot of your compiler checks.Detecting gcc is actually quite nontrivial as it doesn't expose a nice macro like clang does with
__clang__, hence I usedBOOST_GCCandBOOST_LIBSTDCXX_VERSIONfromboost/config.hppaccordingly.In some cases I was unsure if you encountered an issue with concepts support in old gcc, or incomplete ranges support in old libstdc++. Particularly in
replaceandtransform_replace.