From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 45CC63839C5F; Mon, 16 May 2022 15:49:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45CC63839C5F Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jonathan Wakely To: glibc-cvs@sourceware.org Subject: [glibc] sys/cdefs.h: Do not require C++ compilers to define __STDC__ X-Act-Checkin: glibc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 61a87530108ec9181e1b18a9b727ec3cc3ba7532 X-Git-Newrev: 21244c70c24db4b3bd7a2169a7a48f637cad5930 Message-Id: <20220516154929.45CC63839C5F@sourceware.org> Date: Mon, 16 May 2022 15:49:29 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 May 2022 15:49:29 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=21244c70c24db4b3bd7a2169a7a48f637cad5930 commit 21244c70c24db4b3bd7a2169a7a48f637cad5930 Author: Jonathan Wakely Date: Fri May 13 14:16:34 2022 +0100 sys/cdefs.h: Do not require C++ compilers to define __STDC__ 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. So only give an error if __GNUC__ is defined and neither __STDC__ nor __cplusplus is defined. Reviewed-by: Fangrui Song Diff: --- 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 1c2b044a0d..f525f67547 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. */