You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Stas Bekman <st...@stason.org> on 2003/02/27 01:03:24 UTC

__attribute__ redefinition warnings

Can apr.h be changed to undef the __attribute__ macro, if it's already 
defined, before redefining it? In the mod_perl 2.0 build we have to include 
include files from perl and apr, so on certain platforms (e.g. aix 4.3.3) 
people get the following warning:

-------- Original Message --------
Subject: make errors with mod_perl-1.99_08 on aix 4.3.3
Date: Wed, 26 Feb 2003 15:34:29 -0500
From: Priest, Darryl - BALTO <da...@piperrudnick.com>
To: 'modperl@perl.apache.org' <mo...@perl.apache.org>

I'm getting the warning for every cc in the make:

"/usr/local/perl5.8.0/lib/5.8.0/aix/CORE/config.h", line 41.9: 1506-236 (W)
Macro name __attribute__ has been redefined.
"/usr/local/perl5.8.0/lib/5.8.0/aix/CORE/config.h", line 41.9: 1506-358 (I)
"__attribute__" is defined on line 28 of /usr/local/apache/include/apr.h.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: __attribute__ redefinition warnings

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 06:47 PM 3/5/2003, Stas Bekman wrote:
>William A. Rowe, Jr. wrote:
>>Stas, to avoid clobbering what the clib headers already do, would...
>>#ifndef __attribute__
>>#define __attribute__(__x)
>>#endif
>>solve the problem as well?  Does defined(_foo_) pick up _foo_(x) declarations?
>>If not is there such a beast?
>
>I suppose that this will do. If I remember correcly it doesn't matter what the argumets are, but the symbol itself. We aren't in C++ here ;)
>
>but it's possible that that other macro was defined differently. If that's the case, shouldn't this be overriden? (that's why I've done an unconditional #undef). But I'm not sure what's the correct way to handle this.
>
>FWIW, perl defines it as:
>
>/* HASATTRIBUTE:
> *      This symbol indicates the C compiler can check for function attributes,
> *      such as printf formats. This is normally only supported by GNU cc.
> */
>/*#define HASATTRIBUTE  / **/
>#ifndef HASATTRIBUTE
>#define __attribute__(_arg_)
>#endif
>
>on platforms where __attribute__ is supported, it uncomments:
>/*#define HASATTRIBUTE  / **/

Right.  We shouldn't unconditionally define __attribute__.  If it is
supported (e.g. by gcc) then let that definition be.

Bill 


Re: __attribute__ redefinition warnings

Posted by Stas Bekman <st...@stason.org>.
William A. Rowe, Jr. wrote:
> At 06:55 PM 3/5/2003, Stas Bekman wrote:
>>>From browsing perl sources, it seems that this is the proper way to do that:
> 
>>#ifdef  __attribute__           /* Avoid possible redefinition errors */
>>#undef  __attribute__
>>#endif
>>#define __attribute__(__x)
>>#endif
> 
> 
> --1 - you would eliminate the ability for us to pick up thinks like apr_xprintf()
> invalid formatting strings and the like where they are supported.

I don't know what's the proper way to do that. I was just looking at how other 
projects have done this.

So your suggested:

#ifndef __attribute__
#define __attribute__(__x)
#endif

is fine by me.

> Your snippet isn't balanced above, was their something more?

oops, kill the last #endif

it was a part of the wrapper
#ifndef HASATTRIBUTE
...
#endif

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: __attribute__ redefinition warnings

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 06:55 PM 3/5/2003, Stas Bekman wrote:
>>From browsing perl sources, it seems that this is the proper way to do that:
>
>#ifdef  __attribute__           /* Avoid possible redefinition errors */
>#undef  __attribute__
>#endif
>#define __attribute__(__x)
>#endif

--1 - you would eliminate the ability for us to pick up thinks like apr_xprintf()
invalid formatting strings and the like where they are supported.

Your snippet isn't balanced above, was their something more?

Bill

Bill




Re: __attribute__ redefinition warnings

Posted by Stas Bekman <st...@stason.org>.
 From browsing perl sources, it seems that this is the proper way to do that:

#ifdef  __attribute__           /* Avoid possible redefinition errors */
#undef  __attribute__
#endif
#define __attribute__(__x)
#endif


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: __attribute__ redefinition warnings

Posted by Stas Bekman <st...@stason.org>.
William A. Rowe, Jr. wrote:
> Stas, to avoid clobbering what the clib headers already do, would...
> 
> #ifndef __attribute__
> #define __attribute__(__x)
> #endif
> 
> solve the problem as well?  Does defined(_foo_) pick up _foo_(x) declarations?
> If not is there such a beast?

I suppose that this will do. If I remember correcly it doesn't matter what the 
argumets are, but the symbol itself. We aren't in C++ here ;)

but it's possible that that other macro was defined differently. If that's the 
case, shouldn't this be overriden? (that's why I've done an unconditional 
#undef). But I'm not sure what's the correct way to handle this.

FWIW, perl defines it as:

/* HASATTRIBUTE:
  *      This symbol indicates the C compiler can check for function attributes,
  *      such as printf formats. This is normally only supported by GNU cc.
  */
/*#define HASATTRIBUTE  / **/
#ifndef HASATTRIBUTE
#define __attribute__(_arg_)
#endif

on platforms where __attribute__ is supported, it uncomments:
/*#define HASATTRIBUTE  / **/

> Bill
> 
> At 05:52 PM 3/5/2003, Stas Bekman wrote:
> 
>>Stas Bekman wrote:
>>
>>>Can apr.h be changed to undef the __attribute__ macro, if it's already defined, before redefining it? In the mod_perl 2.0 build we have to include include files from perl and apr, so on certain platforms (e.g. aix 4.3.3) people get the following warning:
>>>-------- Original Message --------
>>>Subject: make errors with mod_perl-1.99_08 on aix 4.3.3
>>>Date: Wed, 26 Feb 2003 15:34:29 -0500
>>>From: Priest, Darryl - BALTO <da...@piperrudnick.com>
>>>To: 'modperl@perl.apache.org' <mo...@perl.apache.org>
>>>I'm getting the warning for every cc in the make:
>>>"/usr/local/perl5.8.0/lib/5.8.0/aix/CORE/config.h", line 41.9: 1506-236 (W)
>>>Macro name __attribute__ has been redefined.
>>>"/usr/local/perl5.8.0/lib/5.8.0/aix/CORE/config.h", line 41.9: 1506-358 (I)
>>>"__attribute__" is defined on line 28 of /usr/local/apache/include/apr.h.
>>
>>will this work? (hopefully sliding into 0.9.2)
>>
>>Index: include/apr.h.in
>>===================================================================
>>RCS file: /home/cvspublic/apr/include/apr.h.in,v
>>retrieving revision 1.119
>>diff -u -r1.119 apr.h.in
>>--- include/apr.h.in    16 Feb 2003 10:07:54 -0000      1.119
>>+++ include/apr.h.in    5 Mar 2003 23:52:46 -0000
>>@@ -94,6 +94,7 @@
>>    (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\
>>    defined(NEXT)
>>#define APR_INLINE
>>+#undef __attribute__
>>#define __attribute__(__x)
>>#define APR_HAS_INLINE         0
>>#else
>>
>>
>>__________________________________________________________________
>>Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
>>http://stason.org/    mod_perl Guide ---> http://perl.apache.org
>>mailto:stas@stason.org http://use.perl.org http://apacheweek.com
>>http://modperlbook.org http://apache.org  http://ticketmaster.com
> 
> 


-- 


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: __attribute__ redefinition warnings

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Stas, to avoid clobbering what the clib headers already do, would...

#ifndef __attribute__
#define __attribute__(__x)
#endif

solve the problem as well?  Does defined(_foo_) pick up _foo_(x) declarations?
If not is there such a beast?

Bill

At 05:52 PM 3/5/2003, Stas Bekman wrote:
>Stas Bekman wrote:
>>Can apr.h be changed to undef the __attribute__ macro, if it's already defined, before redefining it? In the mod_perl 2.0 build we have to include include files from perl and apr, so on certain platforms (e.g. aix 4.3.3) people get the following warning:
>>-------- Original Message --------
>>Subject: make errors with mod_perl-1.99_08 on aix 4.3.3
>>Date: Wed, 26 Feb 2003 15:34:29 -0500
>>From: Priest, Darryl - BALTO <da...@piperrudnick.com>
>>To: 'modperl@perl.apache.org' <mo...@perl.apache.org>
>>I'm getting the warning for every cc in the make:
>>"/usr/local/perl5.8.0/lib/5.8.0/aix/CORE/config.h", line 41.9: 1506-236 (W)
>>Macro name __attribute__ has been redefined.
>>"/usr/local/perl5.8.0/lib/5.8.0/aix/CORE/config.h", line 41.9: 1506-358 (I)
>>"__attribute__" is defined on line 28 of /usr/local/apache/include/apr.h.
>
>will this work? (hopefully sliding into 0.9.2)
>
>Index: include/apr.h.in
>===================================================================
>RCS file: /home/cvspublic/apr/include/apr.h.in,v
>retrieving revision 1.119
>diff -u -r1.119 apr.h.in
>--- include/apr.h.in    16 Feb 2003 10:07:54 -0000      1.119
>+++ include/apr.h.in    5 Mar 2003 23:52:46 -0000
>@@ -94,6 +94,7 @@
>     (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\
>     defined(NEXT)
> #define APR_INLINE
>+#undef __attribute__
> #define __attribute__(__x)
> #define APR_HAS_INLINE         0
> #else
>
>
>__________________________________________________________________
>Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
>http://stason.org/    mod_perl Guide ---> http://perl.apache.org
>mailto:stas@stason.org http://use.perl.org http://apacheweek.com
>http://modperlbook.org http://apache.org  http://ticketmaster.com



Re: __attribute__ redefinition warnings

Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> Can apr.h be changed to undef the __attribute__ macro, if it's already 
> defined, before redefining it? In the mod_perl 2.0 build we have to 
> include include files from perl and apr, so on certain platforms (e.g. 
> aix 4.3.3) people get the following warning:
> 
> -------- Original Message --------
> Subject: make errors with mod_perl-1.99_08 on aix 4.3.3
> Date: Wed, 26 Feb 2003 15:34:29 -0500
> From: Priest, Darryl - BALTO <da...@piperrudnick.com>
> To: 'modperl@perl.apache.org' <mo...@perl.apache.org>
> 
> I'm getting the warning for every cc in the make:
> 
> "/usr/local/perl5.8.0/lib/5.8.0/aix/CORE/config.h", line 41.9: 1506-236 (W)
> Macro name __attribute__ has been redefined.
> "/usr/local/perl5.8.0/lib/5.8.0/aix/CORE/config.h", line 41.9: 1506-358 (I)
> "__attribute__" is defined on line 28 of /usr/local/apache/include/apr.h.

will this work? (hopefully sliding into 0.9.2)

Index: include/apr.h.in
===================================================================
RCS file: /home/cvspublic/apr/include/apr.h.in,v
retrieving revision 1.119
diff -u -r1.119 apr.h.in
--- include/apr.h.in    16 Feb 2003 10:07:54 -0000      1.119
+++ include/apr.h.in    5 Mar 2003 23:52:46 -0000
@@ -94,6 +94,7 @@
      (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\
      defined(NEXT)
  #define APR_INLINE
+#undef __attribute__
  #define __attribute__(__x)
  #define APR_HAS_INLINE         0
  #else


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com