mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Zhao, Weiming" <weimingz@codeaurora.org>
To: musl@lists.openwall.com
Subject: swap two macro tests to avoid warning
Date: Thu, 11 Aug 2016 10:34:40 -0700	[thread overview]
Message-ID: <b7f79af8-3861-3738-0459-9c5a7faabc29@codeaurora.org> (raw)

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



             reply	other threads:[~2016-08-11 17:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-11 17:34 Zhao, Weiming [this message]
2016-08-11 18:37 ` Rich Felker
2016-08-11 23:13   ` Zhao, Weiming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b7f79af8-3861-3738-0459-9c5a7faabc29@codeaurora.org \
    --to=weimingz@codeaurora.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).