autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: probing for compiler attributes?


From: Joshua Hoblitt
Subject: Re: probing for compiler attributes?
Date: Wed, 8 Aug 2007 14:23:57 -1000

On Wed, Aug 08, 2007 at 10:16:18AM +0200, Luca Dionisi wrote:
> On 8/8/07, John W. Eaton <address@hidden> wrote:
> > On  7-Aug-2007, Joshua Hoblitt wrote:
> >
> > | Is there a pre-canned AC macro or other reliable means of testing for
> > | compiler attributes?
> > |
> > | I have an awful lot of code that looks something like this:
> > |
> > |       void *myfunc(char *myvar
> > |       #ifdef __GNUC__
> > |       ) __attribute__((malloc));
> > |       # else // ifdef __GNUC__
> > |       );
> > |       #endif // ifdef __GNUC__
> > |
> > | and it has to the potential to get a lot worse if I have to start testing
> > | for what version of GNUC we have to use a new attribute.
> >
> > Ugh.  Don't do it like that.  Instead, write something like
> >
> >   your-config-header.h:
> >   --------------------
> >   #ifdef __GNUC__
> >   #define ATTR_MALLOC __attribute__((malloc))
> >   #else
> >   #define ATTR_MALLOC
> >   #endif
> >
> > and then in your code, just use
> >
> >   #include "your-config-header.h"
> >   ...
> >   void *myfunc (char *myvar) ATTR_MALLOC;
> >
> > You may still want some autoconf macros to check whether the
> > attributes are supported, but with this style it won't be so messy
> > since the cpp #ifdefs only have to appear in one place.
> >
> > jwe
> >
> >
> > _______________________________________________
> > Autoconf mailing list
> > address@hidden
> > http://lists.gnu.org/mailman/listinfo/autoconf
> >
> 
> Isn't that already provided?
> 
> I can read these 2 lines
> 
>  ax_gcc_malloc_call
>     defines GCC_MALLOC_CALL to __attribute__((__malloc__)) if ok

Perfect! Thanks.

-J

--

Attachment: pgpLPP7caeieh.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]