Generating a deprecation warning for macros

Florian Weimer fweimer@redhat.com
Wed Sep 26 08:31:00 GMT 2012


On 09/20/2012 06:47 PM, Ian Lance Taylor wrote:
> On Thu, Sep 20, 2012 at 7:23 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> I would like to generate a deprecation warning for macros.  In the header
>> file, I would like to have:
>>
>> #define FOO 127
>> /* do something with FOO to mark it deprecated */
>>
>> And in client code which includes the header,
>>
>>    printf("%d", FOO);
>>
>> should print a compile-time warning.  Is this possible without changing GCC
>> itself?
>
> I don't think so.  We have deprecated attributes for functions,
> variables, and types, but there is no notion of an attribute for
> macros, and there is no support for marking a macro as deprecated.

Thanks for checking.

I've submitted a patch for issuing arbitrary diagnostics from macros: 
<http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01710.html>

This would provide a reasonable approximation.  Adding machinery to keep 
a deprecation message without increasing storage requirements for all 
macros would have been a bit more involved.

-- 
Florian Weimer / Red Hat Product Security Team



More information about the Gcc-help mailing list