[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: probing for compiler attributes?
From: |
Luca Dionisi |
Subject: |
Re: probing for compiler attributes? |
Date: |
Thu, 9 Aug 2007 13:14:19 +0200 |
On 8/9/07, Joshua Hoblitt <address@hidden> wrote:
> On Tue, Aug 07, 2007 at 08:43:54PM -0400, John W. Eaton wrote:
> > 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;
>
> The more I think about it the more I think this is a bad idea for
> library code. It certainly makes the code more tidy but doesn't this
> end up screwing any application that tries to link against your code? I
> don't ever install config.h.
>
I don't see it as more harmful than putting #ifdef in .c files.
You must not install config.h, indeed.
Anyway, ax_gcc_malloc_call should do that exact thing for you
behind the scenes. I think.