Tailoring warnings

Yang Zhang yanghatespam@gmail.com
Sat Feb 21 23:26:00 GMT 2009


Christoph Bartoschek wrote:
> Am Freitag 20 Februar 2009 schrieb Yang Zhang:
>> Can gcc restrict certain warnings to exclude certain files or to apply
>> only to certain files?  E.g., I'd like to have -Wold-style-cast,
>> -Wconversion, and some others to apply only to my own code, and not
>> (say) boost headers.  (I do use -Werror.)  Thanks in advance.
> 
> You can ignore warnings from headers that are not your own by using -isystem 
> instead of -I.
> 
> Christoph

Thanks, this led me to one fix.  I was previously using CPATH for 
indicating where to find my system files.  However, CPATH gets treated 
as -I.  I'm now using CPLUS_INCLUDE_PATH/C_INCLUDE_PATH, which get 
treated as -isystem and don't lead to warnings.

I'm also working on a common C++ header library that's included by 
several of my projects; this is found on the system path, and it would 
be nice if I could enable warnings for these.  Still, -isystem is a 
major improvement over the prior situation.
-- 
Yang Zhang
http://www.mit.edu/~y_z/



More information about the Gcc-help mailing list