public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] libstdc++/65473 Make <ciso646> define libstdc++ version macros.
@ 2015-09-03 11:05 Jonathan Wakely
  2015-09-03 19:32 ` Martin Sebor
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2015-09-03 11:05 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

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?


[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 2109 bytes --]

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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] libstdc++/65473 Make <ciso646> define libstdc++ version macros.
  2015-09-03 11:05 [patch] libstdc++/65473 Make <ciso646> define libstdc++ version macros Jonathan Wakely
@ 2015-09-03 19:32 ` Martin Sebor
  2015-09-03 20:40   ` Jonathan Wakely
  2015-09-04  9:28   ` Jonathan Wakely
  0 siblings, 2 replies; 4+ messages in thread
From: Martin Sebor @ 2015-09-03 19:32 UTC (permalink / raw)
  To: Jonathan Wakely, libstdc++, gcc-patches

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] libstdc++/65473 Make <ciso646> define libstdc++ version macros.
  2015-09-03 19:32 ` Martin Sebor
@ 2015-09-03 20:40   ` Jonathan Wakely
  2015-09-04  9:28   ` Jonathan Wakely
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2015-09-03 20:40 UTC (permalink / raw)
  To: Martin Sebor; +Cc: libstdc++, gcc-patches

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] libstdc++/65473 Make <ciso646> define libstdc++ version macros.
  2015-09-03 19:32 ` Martin Sebor
  2015-09-03 20:40   ` Jonathan Wakely
@ 2015-09-04  9:28   ` Jonathan Wakely
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2015-09-04  9:28 UTC (permalink / raw)
  To: Martin Sebor; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1597 bytes --]

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. 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.

OK, here's a patch to add <bits/c++config.h> to all the <cxxx> headers
that don't have it.

Tested powerpc64le-linux, committed to trunk.

I must admit I don't understand why many of the <cxxx> headers
include the <xxx.h> header and <bits/c++config.h> outside the include
guard ... AFAIK it's only needed for <assert.h>, and will lead to
<cxxx> headers being unnecessarily re-opened if included twice, but
I'm not going to change that.


>  <cuchar>             <stdin>:1:18: fatal error: cuchar: No such file 
>or directory
>compilation terminated.
>0

Ed sent a patch to add <cuchar> which I'm going to tidy up and commit.


[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 6606 bytes --]

commit a4a655dacdcfadfac3f90777e574e14acfdbc973
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Sep 4 10:02:43 2015 +0100

    Make all <cxxx> headers include <bits/c++config.h>
    
    	PR libstdc++/65473
    	* include/c/cassert: Include <bits/c++config.h>.
    	* include/c/cerrno: Likewise.
    	* include/c/cfloat: Likewise.
    	* include/c/ciso646: Likewise.
    	* include/c/climits: Likewise.
    	* include/c_global/cassert: Likewise.
    	* include/c_global/cerrno: Likewise.
    	* include/c_global/cfloat: Likewise.
    	* include/c_global/ciso646: Likewise.
    	* include/c_global/climits: Likewise.
    	* include/c_std/cassert: Likewise.
    	* include/c_std/cerrno: Likewise.
    	* include/c_std/cfloat: Likewise.
    	* include/c_std/ciso646: Likewise.
    	* include/c_std/climits: Likewise.

diff --git a/libstdc++-v3/include/c/cassert b/libstdc++-v3/include/c/cassert
index 46e4172..3965d16 100644
--- a/libstdc++-v3/include/c/cassert
+++ b/libstdc++-v3/include/c/cassert
@@ -30,4 +30,5 @@
 
 #pragma GCC system_header
 
+#include <bits/c++config.h>
 #include_next <assert.h>
diff --git a/libstdc++-v3/include/c/cerrno b/libstdc++-v3/include/c/cerrno
index 1d56cb4..6ea1d4c 100644
--- a/libstdc++-v3/include/c/cerrno
+++ b/libstdc++-v3/include/c/cerrno
@@ -40,6 +40,7 @@
 
 #pragma GCC system_header
 
+#include <bits/c++config.h>
 #include_next <errno.h>
 
 // Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
diff --git a/libstdc++-v3/include/c/cfloat b/libstdc++-v3/include/c/cfloat
index 25cfa64..282eb31 100644
--- a/libstdc++-v3/include/c/cfloat
+++ b/libstdc++-v3/include/c/cfloat
@@ -31,6 +31,7 @@
 
 #pragma GCC system_header
 
+#include <bits/c++config.h>
 #include_next <float.h>
 
 #endif
diff --git a/libstdc++-v3/include/c/ciso646 b/libstdc++-v3/include/c/ciso646
index 125f166..6eca274 100644
--- a/libstdc++-v3/include/c/ciso646
+++ b/libstdc++-v3/include/c/ciso646
@@ -27,6 +27,12 @@
  *  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++.
  */
+#ifndef _GLIBCXX_CISO646
+#define _GLIBCXX_CISO646
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#endif
diff --git a/libstdc++-v3/include/c/climits b/libstdc++-v3/include/c/climits
index f8b19d5..5333af9 100644
--- a/libstdc++-v3/include/c/climits
+++ b/libstdc++-v3/include/c/climits
@@ -31,6 +31,7 @@
 
 #pragma GCC system_header
 
+#include <bits/c++config.h>
 #include_next <limits.h>
 
 #endif
diff --git a/libstdc++-v3/include/c_global/cassert b/libstdc++-v3/include/c_global/cassert
index e555a38..f404560 100644
--- a/libstdc++-v3/include/c_global/cassert
+++ b/libstdc++-v3/include/c_global/cassert
@@ -40,4 +40,5 @@
 
 #pragma GCC system_header
 
+#include <bits/c++config.h>
 #include <assert.h>
diff --git a/libstdc++-v3/include/c_global/cerrno b/libstdc++-v3/include/c_global/cerrno
index 7060b1e..9f173c5 100644
--- a/libstdc++-v3/include/c_global/cerrno
+++ b/libstdc++-v3/include/c_global/cerrno
@@ -38,6 +38,7 @@
 
 #pragma GCC system_header
 
+#include <bits/c++config.h>
 #include <errno.h>
 
 #ifndef _GLIBCXX_CERRNO
diff --git a/libstdc++-v3/include/c_global/cfloat b/libstdc++-v3/include/c_global/cfloat
index 2c4ae28..50f7d3d 100644
--- a/libstdc++-v3/include/c_global/cfloat
+++ b/libstdc++-v3/include/c_global/cfloat
@@ -38,6 +38,7 @@
 
 #pragma GCC system_header
 
+#include <bits/c++config.h>
 #include <float.h>
 
 #ifndef _GLIBCXX_CFLOAT
diff --git a/libstdc++-v3/include/c_global/ciso646 b/libstdc++-v3/include/c_global/ciso646
index 818db67..93fded4 100644
--- a/libstdc++-v3/include/c_global/ciso646
+++ b/libstdc++-v3/include/c_global/ciso646
@@ -27,7 +27,12 @@
  *  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++.
  */
+#ifndef _GLIBCXX_CISO646
+#define _GLIBCXX_CISO646
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#endif
diff --git a/libstdc++-v3/include/c_global/climits b/libstdc++-v3/include/c_global/climits
index e3da66c..d6e7994 100644
--- a/libstdc++-v3/include/c_global/climits
+++ b/libstdc++-v3/include/c_global/climits
@@ -38,6 +38,7 @@
 
 #pragma GCC system_header
 
+#include <bits/c++config.h>
 #include <limits.h>
 
 #ifndef _GLIBCXX_CLIMITS
diff --git a/libstdc++-v3/include/c_std/cassert b/libstdc++-v3/include/c_std/cassert
index ea6daea..641b03a 100644
--- a/libstdc++-v3/include/c_std/cassert
+++ b/libstdc++-v3/include/c_std/cassert
@@ -40,4 +40,5 @@
 
 #pragma GCC system_header
 
+#include <bits/c++config.h>
 #include <assert.h>
diff --git a/libstdc++-v3/include/c_std/cerrno b/libstdc++-v3/include/c_std/cerrno
index 06618b9..ef298fa 100644
--- a/libstdc++-v3/include/c_std/cerrno
+++ b/libstdc++-v3/include/c_std/cerrno
@@ -41,6 +41,7 @@
 
 #pragma GCC system_header
 
+#include <bits/c++config.h>
 #include <errno.h>
 
 // Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
diff --git a/libstdc++-v3/include/c_std/cfloat b/libstdc++-v3/include/c_std/cfloat
index d730af9..01f1724 100644
--- a/libstdc++-v3/include/c_std/cfloat
+++ b/libstdc++-v3/include/c_std/cfloat
@@ -41,6 +41,7 @@
 
 #pragma GCC system_header
 
+#include <bits/c++config.h>
 #include <float.h>
 
 #endif
diff --git a/libstdc++-v3/include/c_std/ciso646 b/libstdc++-v3/include/c_std/ciso646
index 08cdf24..7829d72 100644
--- a/libstdc++-v3/include/c_std/ciso646
+++ b/libstdc++-v3/include/c_std/ciso646
@@ -27,7 +27,12 @@
  *  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++.
  */
+#ifndef _GLIBCXX_CISO646
+#define _GLIBCXX_CISO646
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#endif
diff --git a/libstdc++-v3/include/c_std/climits b/libstdc++-v3/include/c_std/climits
index 348d4c3..bffa892 100644
--- a/libstdc++-v3/include/c_std/climits
+++ b/libstdc++-v3/include/c_std/climits
@@ -41,6 +41,7 @@
 
 #pragma GCC system_header
 
+#include <bits/c++config.h>
 #include <limits.h>
 
 #endif

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-04  9:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-03 11:05 [patch] libstdc++/65473 Make <ciso646> define libstdc++ version macros Jonathan Wakely
2015-09-03 19:32 ` Martin Sebor
2015-09-03 20:40   ` Jonathan Wakely
2015-09-04  9:28   ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).