[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pure and const function attributes
From: |
Marc Nieper-Wißkirchen |
Subject: |
Re: pure and const function attributes |
Date: |
Fri, 1 May 2020 09:58:32 +0200 |
Am Fr., 1. Mai 2020 um 02:46 Uhr schrieb Paul Eggert <address@hidden>:
>
> On 4/30/20 6:37 AM, Marc Nieper-Wißkirchen wrote:
> > P.S.: It would also be helpful so that warnings coming from
> > "-Wsuggest-attribute=pure" can be handled for the GCC without
> > affecting other compilers.
>
> So, something like the attached file for modules/attribute-gcc? You can put
> ATTRIBUTE_PURE in the declaration for a function, and for non-GCC compilers it
> expands to nothing.
Yes. And this can even be reused by many existing Gnulib modules,
which currently contain code like:
#if __GNUC__ >= 3
__attribute__ ((__pure__))
#endif
A feature test in configure for the attributes would be even better
because other compilers like Clang will also accept the GCC attributes
(and different GCC versions may support different attributes in the
future).
To my knowledge, C2x will standardize attributes so one should keep an
eye on this to make this new Gnulib module future-proof. (The
standardized attributes seem to have vendor prefixes.)
- Re: pure and const function attributes,
Marc Nieper-Wißkirchen <=