From: "R. Diez" <rdiezmail-newlib@yahoo.de>
To: newlib@sourceware.org
Subject: [PATCH 0/1] Fix some warnings in the public headers
Date: Sun, 11 Apr 2021 12:31:26 +0200 [thread overview]
Message-ID: <20210411103126.714706-1-rdiezmail-newlib@yahoo.de> (raw)
In-Reply-To: <20210411103126.714706-1-rdiezmail-newlib.ref@yahoo.de>
Hi all:
I am experimenting with Newlib and I am not using option -isystem <path>, but the normal -I<path>, so I get to see more compilation warnings than usual.
Maybe I am seeing more warnings because I am building in C++ mode.
I have prepared a patch to fix those warnings, see below. Notes about the patch are:
About __ARM_FP:
The documentation for __ARM_FP states "Set if hardware floating-point is available", so I was getting an "is not defined, evaluates to 0 [-Wundef]" warning.
About _FORTIFY_SOURCE:
The GCC manual states "when the _FORTIFY_SOURCE macro is defined to a non-zero value", and that symbol was not defined in my build, so I was getting an "is not defined, evaluates to 0 [-Wundef]" warning.
About __assert_func():
I was getting this warning:
redundant redeclaration of 'void __assert_func(const char*, int, const char*, const char*)' in same scope [-Wredundant-decls]
About __STDC_VERSION__:
I was getting an "is not defined, evaluates to 0 [-Wundef]" warning when compiling in C++ mode.
About _sig_func:
I was getting this warning:
warning: unnecessary parentheses in declaration of '_sig_func' [-Wparentheses]
Thanks in advance,
rdiez
R. Diez (1):
Fix some compilation warnings.
newlib/libc/include/assert.h | 5 ++++-
newlib/libc/include/machine/ieeefp.h | 2 +-
newlib/libc/include/sys/features.h | 2 +-
newlib/libc/include/sys/reent.h | 4 ++--
4 files changed, 8 insertions(+), 5 deletions(-)
--
2.31.1
From dfb65e9d0b3e3335318e3cf85828ea4a14e252f0 Mon Sep 17 00:00:00 2001
From: "R. Diez" <rdiezmail-newlib@yahoo.de>
Date: Sun, 11 Apr 2021 11:48:02 +0200
Subject: [PATCH 1/1] Fix some compilation warnings.
Signed-off-by: R. Diez <rdiezmail-newlib@yahoo.de>
---
newlib/libc/include/assert.h | 5 ++++-
newlib/libc/include/machine/ieeefp.h | 2 +-
newlib/libc/include/sys/features.h | 2 +-
newlib/libc/include/sys/reent.h | 4 ++--
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/newlib/libc/include/assert.h b/newlib/libc/include/assert.h
index b9e5e9b4a..a15e7fbae 100644
--- a/newlib/libc/include/assert.h
+++ b/newlib/libc/include/assert.h
@@ -36,12 +36,15 @@ extern "C" {
# endif /* !__ASSERT_FUNC */
#endif /* !NDEBUG */
+#ifndef __ASSERT_WAS_DECLARED /* Prevent "redundant redeclaration" warning when including this file multiple times. */
+#define __ASSERT_WAS_DECLARED
void __assert (const char *, int, const char *)
_ATTRIBUTE ((__noreturn__));
void __assert_func (const char *, int, const char *, const char *)
_ATTRIBUTE ((__noreturn__));
+#endif /* #ifndef __ASSERT_WAS_DECLARED */
-#if __STDC_VERSION__ >= 201112L && !defined __cplusplus
+#if !defined __cplusplus && __STDC_VERSION__ >= 201112L
# define static_assert _Static_assert
#endif
diff --git a/newlib/libc/include/machine/ieeefp.h b/newlib/libc/include/machine/ieeefp.h
index 3c1f41e03..37f7661cb 100644
--- a/newlib/libc/include/machine/ieeefp.h
+++ b/newlib/libc/include/machine/ieeefp.h
@@ -78,7 +78,7 @@
# else
# define __IEEE_BIG_ENDIAN
# endif
-# if __ARM_FP & 0x8
+# if defined(__ARM_FP) && (__ARM_FP & 0x8)
# define __OBSOLETE_MATH_DEFAULT 0
# endif
#else
diff --git a/newlib/libc/include/sys/features.h b/newlib/libc/include/sys/features.h
index 218807178..65f5af763 100644
--- a/newlib/libc/include/sys/features.h
+++ b/newlib/libc/include/sys/features.h
@@ -319,7 +319,7 @@ extern "C" {
#define __XSI_VISIBLE 0
#endif
-#if _FORTIFY_SOURCE > 0 && !defined(__cplusplus) && !defined(__lint__) && \
+#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && !defined(__cplusplus) && !defined(__lint__) && \
(__OPTIMIZE__ > 0 || defined(__clang__)) && __GNUC_PREREQ__(4, 1)
# if _FORTIFY_SOURCE > 1
# define __SSP_FORTIFY_LEVEL 2
diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reent.h
index 74b70e9c0..f62e5817b 100644
--- a/newlib/libc/include/sys/reent.h
+++ b/newlib/libc/include/sys/reent.h
@@ -409,7 +409,7 @@ struct _reent
char *_asctime_buf;
/* signal info */
- void (**(_sig_func))(int);
+ void (**_sig_func)(int);
# ifndef _REENT_GLOBAL_ATEXIT
/* atexit stuff */
@@ -682,7 +682,7 @@ struct _reent
# endif
/* signal info */
- void (**(_sig_func))(int);
+ void (**_sig_func)(int);
/* These are here last so that __FILE can grow without changing the offsets
of the above members (on the off chance that future binary compatibility
--
2.31.1
next parent reply other threads:[~2021-04-11 10:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210411103126.714706-1-rdiezmail-newlib.ref@yahoo.de>
2021-04-11 10:31 ` R. Diez [this message]
2021-04-11 15:12 ` Brian Inglis
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=20210411103126.714706-1-rdiezmail-newlib@yahoo.de \
--to=rdiezmail-newlib@yahoo.de \
--cc=newlib@sourceware.org \
/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.
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).