Ignoring some unused const variables

Chandler Carruth chandlerc at google.com
Mon Oct 27 01:27:00 PDT 2014


On Fri, Oct 24, 2014 at 2:43 PM, Brooks Davis <brooks at freebsd.org> wrote:

> Older code often includes idioms like:
>
> static const char rcsid[] = "$Id: herror.c,v 1.4 2005/04/27 04:56:41 sra
> Exp $";
>
> which are currently warned about with -Wunused-variable unless
> -Wno-unused-const-variable is given.  Unfortunatly the latter masks
> variables that should be removed in some cases.  The following patch causes
> the three rcsid like variables I tripped on in FreeBSD's libc to always be
> ingored.  I'm not sure if this fits the current warnings model, but I found
> it useful.
>

I think that making warnings like this conditional on the variable name
isn't a good idea. Why not 'vcsid' or any number of other possible
spellings?

You can always add an attribute to such a variable declaration to silence
the warning rather than flipping a flag...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141027/39b2f670/attachment.html>


More information about the cfe-commits mailing list