From d6c064e914cba3277d852c9fa27db53f0059ff8c Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 9 Oct 2017 14:58:34 +0100 Subject: Ensure C99 and C11 interfaces are available for C++ [BZ #21326] This patch ensures that the C99 and C11 features required by C++ are defined according to the value of the __cplusplus macro, and not just because G++ always defines _GNU_SOURCE. This will allow G++ to stop defining _GNU_SOURCE some day, without causing the C99 and C11 interfaces to disappear for C++ programs. [BZ #21326] * include/features.h [__cplusplus >= 201103] (__USE_ISOC99): Define. [__cplusplus >= 201703] (__USE_ISOCXX17, __USE_ISOC11): Define. * math/Makefile (test-math-cxx11): New test. * math/test-math-cxx11.cc: New file. --- include/features.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'include/features.h') diff --git a/include/features.h b/include/features.h index c063b33b49..22735ec117 100644 --- a/include/features.h +++ b/include/features.h @@ -76,6 +76,7 @@ __USE_ISOC11 Define ISO C11 things. __USE_ISOC99 Define ISO C99 things. __USE_ISOC95 Define ISO C90 AMD1 (C95) things. + __USE_ISOCXX11 Define ISO C++11 things. __USE_POSIX Define IEEE Std 1003.1 things. __USE_POSIX2 Define IEEE Std 1003.2 things. __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. @@ -238,13 +239,17 @@ # define __USE_ISOC95 1 #endif +#ifdef __cplusplus +/* This is to enable compatibility for ISO C++17. */ +# if __cplusplus >= 201703L +# define __USE_ISOC11 1 +# endif /* This is to enable compatibility for ISO C++11. - - So far g++ does not provide a macro. Check the temporary macro for - now, too. */ -#if ((defined __cplusplus && __cplusplus >= 201103L) \ - || defined __GXX_EXPERIMENTAL_CXX0X__) -# define __USE_ISOCXX11 1 + Check the temporary macro for now, too. */ +# if __cplusplus >= 201103L || defined __GXX_EXPERIMENTAL_CXX0X__ +# define __USE_ISOCXX11 1 +# define __USE_ISOC99 1 +# endif #endif /* If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE -- cgit 1.4.1