[PATCH 0/1] Fix some warnings in the public headers
"R. Diez via Newlib" <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
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" <[email protected]> Date: Sun, 11 Apr 2021 11:48:02 +0200 Subject: [PATCH 1/1] Fix some compilation warnings. Signed-off-by: R. Diez <[email protected]> --- 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