From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10371 Path: news.gmane.org!.POSTED!not-for-mail From: "Zhao, Weiming" Newsgroups: gmane.linux.lib.musl.general Subject: swap two macro tests to avoid warning Date: Thu, 11 Aug 2016 10:34:40 -0700 Message-ID: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1470936902 29269 195.159.176.226 (11 Aug 2016 17:35:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 11 Aug 2016 17:35:02 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 To: musl@lists.openwall.com Original-X-From: musl-return-10384-gllmg-musl=m.gmane.org@lists.openwall.com Thu Aug 11 19:34:59 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1bXtsf-0007Ve-MA for gllmg-musl@m.gmane.org; Thu, 11 Aug 2016 19:34:57 +0200 Original-Received: (qmail 9321 invoked by uid 550); 11 Aug 2016 17:34:55 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 9285 invoked from network); 11 Aug 2016 17:34:53 -0000 Xref: news.gmane.org gmane.linux.lib.musl.general:10371 Archived-At: HI, When I use MUSL in some C++ project building, I got the warning of '__STDC_VERSION__' is not defined How about we first check if __cplusplus is defined? if yes, the the __STD_VERSION__ test will be short circuited and won't trigger the warning. diff --git a/include/assert.h b/include/assert.h index 8571f21..9d7a05b 100644 --- a/include/assert.h +++ b/include/assert.h @@ -12,7 +12,7 @@ #endif #endif -#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus) +#if !defined(__cplusplus) && __STDC_VERSION__ >= 201112L #define static_assert _Static_assert #endif diff --git a/include/features.h b/include/features.h index 3cc3e57..64671b3 100644 --- a/include/features.h +++ b/include/features.h @@ -16,21 +16,27 @@ #define _XOPEN_SOURCE 700 #endif +#ifndef __cplusplus #if __STDC_VERSION__ >= 199901L #define __restrict restrict #elif !defined(__GNUC__) #define __restrict #endif +#endif -#if __STDC_VERSION__ >= 199901L || defined(__cplusplus) +#if defined(__cplusplus) || __STDC_VERSION__ >= 199901L #define __inline inline #endif +#ifdef __cplusplus +#define _Noreturn [[noreturn]] +#else #if __STDC_VERSION__ >= 201112L #elif defined(__GNUC__) #define _Noreturn __attribute__((__noreturn__)) #else #define _Noreturn #endif +#endif #endif Thanks, Weiming -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation