diff mbox

libstdc++/65473 Make <ciso646> define libstdc++ version macros.

Message ID 20150903105847.GN2631@redhat.com
State New
Headers show

Commit Message

Jonathan Wakely Sept. 3, 2015, 10:58 a.m. UTC
This change would allow including <ciso646> to be used to check for
__GLIBCXX__ and detect whether youre using libstdc++ or not. Howard
Hinnant recommends including that header for libc++ because it has no
other effects in C++.

We could make every <cxxx> header include <bits/c++config.h> so that
any of them can be used, but I can't be bothered doing that change!
This makes it work for the one header that is recommended to be used,
but of course that doesn't help people using older versions of
libstdc++, who still need to include some other header.

Is this worth doing?

Comments

Martin Sebor Sept. 3, 2015, 7:22 p.m. UTC | #1
On 09/03/2015 04:58 AM, Jonathan Wakely wrote:
> This change would allow including <ciso646> to be used to check for
> __GLIBCXX__ and detect whether youre using libstdc++ or not. Howard
> Hinnant recommends including that header for libc++ because it has no
> other effects in C++.
>
> We could make every <cxxx> header include <bits/c++config.h> so that
> any of them can be used, but I can't be bothered doing that change!
> This makes it work for the one header that is recommended to be used,
> but of course that doesn't help people using older versions of
> libstdc++, who still need to include some other header.
>
> Is this worth doing?

I'd say it's worth doing consistently, in every header. Users are
told by others (e.g., on various discussion forums) to expect to
be able to check what C++ library implementation they're using by
including any C++ standard header and testing the known version
macros.

Martin

PS Out of curiosity I looked to see which headers don't include
c++config.g.

$ (for f in cassert ccomplex cctype cerrno cfenv cfloat cinttypes 
ciso646 climits clocale cmath csetjmp csignal cstdalign cstdarg cstdbool 
cstddef cstdint cstdio cstdlib cstring ctgmath ctime cuchar; do printf " 
  %-20s " "<$f>" && echo "#include <$f>" | ~/bin/gcc-5.1.0/bin/g++ -E 
-std=c++14 -xc++ - | grep -l "c++config\.h" | wc -l; done )
   <cassert>            0
   <ccomplex>           1
   <cctype>             1
   <cerrno>             0
   <cfenv>              1
   <cfloat>             0
   <cinttypes>          1
   <ciso646>            0
   <climits>            0
   <clocale>            1
   <cmath>              1
   <csetjmp>            1
   <csignal>            1
   <cstdalign>          1
   <cstdarg>            1
   <cstdbool>           1
   <cstddef>            1
   <cstdint>            1
   <cstdio>             1
   <cstdlib>            1
   <cstring>            1
   <ctgmath>            1
   <ctime>              1
   <cuchar>             <stdin>:1:18: fatal error: cuchar: No such file 
or directory
compilation terminated.
0
Jonathan Wakely Sept. 3, 2015, 7:32 p.m. UTC | #2
On 03/09/15 13:22 -0600, Martin Sebor wrote:
>On 09/03/2015 04:58 AM, Jonathan Wakely wrote:
>>This change would allow including <ciso646> to be used to check for
>>__GLIBCXX__ and detect whether youre using libstdc++ or not. Howard
>>Hinnant recommends including that header for libc++ because it has no
>>other effects in C++.
>>
>>We could make every <cxxx> header include <bits/c++config.h> so that
>>any of them can be used, but I can't be bothered doing that change!
>>This makes it work for the one header that is recommended to be used,
>>but of course that doesn't help people using older versions of
>>libstdc++, who still need to include some other header.
>>
>>Is this worth doing?
>
>I'd say it's worth doing consistently, in every header.

OK, I'll add it to the others as well.
diff mbox

Patch

commit 0ac33b5beb231efc94ce4f0288fad36047f0325e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Sep 3 11:45:29 2015 +0100

    Make <ciso646> define libstdc++ version macros.
    
    	PR libstdc++/65473
    	* include/c/ciso646: Include <bits/c++config.h> and improve comment.
    	* include/c_global/ciso646: Likewise.
    	* include/c_std/ciso646: Likewise.

diff --git a/libstdc++-v3/include/c/ciso646 b/libstdc++-v3/include/c/ciso646
index 125f166..fb537f5 100644
--- a/libstdc++-v3/include/c/ciso646
+++ b/libstdc++-v3/include/c/ciso646
@@ -27,6 +27,6 @@ 
  *  in your programs, rather than any of the "*.h" implementation files.
  *
  *  This is the C++ version of the Standard C Library header @c iso646.h,
- *  and its contents are (mostly) the same as that header, but are all
- *  contained in the namespace @c std.
+ *  which is empty in C++.
  */
+#include <bits/c++config.h>
diff --git a/libstdc++-v3/include/c_global/ciso646 b/libstdc++-v3/include/c_global/ciso646
index 818db67..c59677a 100644
--- a/libstdc++-v3/include/c_global/ciso646
+++ b/libstdc++-v3/include/c_global/ciso646
@@ -27,7 +27,6 @@ 
  *  in your programs, rather than any of the @a *.h implementation files.
  *
  *  This is the C++ version of the Standard C Library header @c iso646.h,
- *  and its contents are (mostly) the same as that header, but are all
- *  contained in the namespace @c std (except for names which are defined
- *  as macros in C).
+ *  which is empty in C++.
  */
+#include <bits/c++config.h>
diff --git a/libstdc++-v3/include/c_std/ciso646 b/libstdc++-v3/include/c_std/ciso646
index 08cdf24..ab44488 100644
--- a/libstdc++-v3/include/c_std/ciso646
+++ b/libstdc++-v3/include/c_std/ciso646
@@ -27,7 +27,6 @@ 
  *  in your programs, rather than any of the @a *.h implementation files.
  *
  *  This is the C++ version of the Standard C Library header @c iso646.h,
- *  and its contents are (mostly) the same as that header, but are all
- *  contained in the namespace @c std (except for names which are defined
- *  as macros in C).
+ *  which is empty in C++.
  */
+#include <bits/c++config.h>