This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [patch] assert.h causing problems with older GCC and XLC
- From: Jeff Johnston <jjohnstn at redhat dot com>
- To: Ken Werner <ken at linux dot vnet dot ibm dot com>
- Cc: newlib at sources dot redhat dot com
- Date: Thu, 17 Jul 2008 16:58:42 -0400
- Subject: Re: [patch] assert.h causing problems with older GCC and XLC
- References: <200807171522.30940.ken@linux.vnet.ibm.com>
Ken,
Your patch should be test for C99 first and use __func__, then test
for __GNUC__ >= 2 as a fall-back as per the information at
http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html
I have made the corresponding patch and checked it in.
-- Jeff J.
Ken Werner wrote:
Hi,
the assert function is using __func__ whenever __GNUC__ is defined, regardless
of the language level provided by the compiler. This causes Problem with the
XLC and probably older GCC versions. This patch first checks the __GNUC__
level then the __STDC_VERSION__. Ok to Apply?
Ken
newlib/ChangeLog:
2008-07-17 Ken Werner <ken.werner@de.ibm.com>
* libc/include/assert.h: Provide .type and .size directives
Index: src/newlib/libc/include/assert.h
===================================================================
--- src.orig/newlib/libc/include/assert.h
+++ src/newlib/libc/include/assert.h
@@ -21,8 +21,12 @@ extern "C" {
# if defined __cplusplus && defined __GNUC__
# define __ASSERT_FUNC __PRETTY_FUNCTION__
- /* C99 requires the use of __func__, gcc also supports it. */
-# elif defined __GNUC__ || __STDC_VERSION__ >= 199901L
+ /* Older versions of GCC recognize __FUNCTION__. */
+# elif defined __GNUC__ >= 2
+# define __ASSERT_FUNC __FUNCTION__
+
+ /* C99 requires the use of __func__. */
+# elif defined __STDC_VERSION__ >= 199901L
# define __ASSERT_FUNC __func__
/* failed to detect __func__ support. */