public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Check for ISO C compilers should also allow C++
@ 2022-05-13 16:31 Jonathan Wakely
  2022-05-13 16:46 ` Florian Weimer
  2022-05-13 17:27 ` Joseph Myers
  0 siblings, 2 replies; 6+ messages in thread
From: Jonathan Wakely @ 2022-05-13 16:31 UTC (permalink / raw)
  To: libc-alpha, carlos, fweimer

Tested x86_64-linux.

There is a suggestion[1] to make clang++ stop defining __STDC__ but it's
blocked by this. The clang++ change will still be blocked while old
Glibc versions are still in use, but we can start the clock ticking by
fixing Glibc now.

[1] https://discourse.llvm.org/t/rfc-stop-defining-the-stdc-and-related-macros-in-c-mode/62468/1

From a quick grep, I don't think any other places in Glibc need a
similar change. Florian pointed out that gnulib overrides
<sys/cdefs.h> and so should make the same change in its version.

OK to push?

-- >8 --

The check for an ISO C compiler assumes that anything GCC-like will
define __STDC__, even if it's actually a C++ compiler. That's currently
true for G++ and compilers like clang++ that also define __GNUC__, but
it might not always be true.

The C++ standard leaves it implementation-defined whether or not
__STDC__ is defined by C++ compilers. And really the check should be
"ISO C or ISO C++ conforming compiler" anyway.
---
 misc/sys/cdefs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index f1faf8292c..aab0e7f6a9 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -27,8 +27,8 @@
 /* The GNU libc does not support any K&R compilers or the traditional mode
    of ISO C compilers anymore.  Check for some of the combinations not
    supported anymore.  */
-#if defined __GNUC__ && !defined __STDC__
-# error "You need a ISO C conforming compiler to use the glibc headers"
+#if defined __GNUC__ && !defined __STDC__ && !defined __cplusplus
+# error "You need a ISO C or C++ conforming compiler to use the glibc headers"
 #endif
 
 /* Some user header file might have defined this before.  */
-- 
2.35.1


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

end of thread, other threads:[~2022-05-16 15:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13 16:31 [PATCH] Check for ISO C compilers should also allow C++ Jonathan Wakely
2022-05-13 16:46 ` Florian Weimer
2022-05-13 17:27 ` Joseph Myers
2022-05-13 17:41   ` Jonathan Wakely
2022-05-14  6:46     ` Fangrui Song
2022-05-16 15:50       ` 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).