From patchwork Fri May 13 16:31:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 53963 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC65D383D816 for ; Fri, 13 May 2022 16:32:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC65D383D816 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1652459543; bh=k4j1wL5qNgXtTukyxhzfa4bBeuEDwVt2H1u6KYntPbw=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=iuMeVetO0hvaNMxU2GjXJBMYoBBbHFb4/iz3nLKicbkTeI7Hzv4hwVxfMuOOQDoJq /re2dMzcicVq5ZJcIpX7GEdCNav2WbHpRhBw7pr9GopPLTpM2qj3LJLPWo8wAoDngD ERW3D/McgJYV3EnNVOXmPRCXDTiCDSWnhoTd08eQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 2501F3857C4A for ; Fri, 13 May 2022 16:32:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2501F3857C4A Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-213-tpamn1a6MRiMOlCtzbxtXg-1; Fri, 13 May 2022 12:32:00 -0400 X-MC-Unique: tpamn1a6MRiMOlCtzbxtXg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 60E2C3C1E335 for ; Fri, 13 May 2022 16:32:00 +0000 (UTC) Received: from localhost (unknown [10.33.36.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84CCA2166B4E; Fri, 13 May 2022 16:31:55 +0000 (UTC) Date: Fri, 13 May 2022 17:31:54 +0100 To: libc-alpha@sourceware.org, carlos@redhat.com, fweimer@redhat.com Subject: [PATCH] Check for ISO C compilers should also allow C++ Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Libc-alpha From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" 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 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. Reviewed-by: Fangrui Song --- 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. */