c - No warnings for headers included by headers in non-current directories -
how can let gcc , clang generate warnings header files included header files in non-current directories? i'm using gcc 4.9.2 , clang 3.6.0.
for example, assume ./include_a.c
includes ./dir/a.h
, ./dir/a.h
includes ./b.h
, , ./b.h
expected generate warning -wconversion
; then, gcc , clang -wconversion
not generate expected warning when compile include_a.c
. -wconversion -wsystem-headers
, expected warning generated, comes many useless warnings system headers. when ./b.h
directly included source file in current directory (such ./include_b.c
), expected warning generated without -wsystem-headers
.
the following shell script reproduces example (the case of clang omitted):
#!/bin/sh mkdir dir echo '#include "b.h"' >dir/a.h echo 'void f() {int = 0; char b = a;}' >b.h echo '#include "dir/a.h"' >include_a.c echo '#include "b.h"' >include_b.c set -x gcc -c include_a.c -wconversion # not generate warning gcc -c include_a.c -wconversion -wsystem-headers # generate warning gcc -c include_b.c -wconversion # generate warning
output:
+ gcc -c include_a.c -wconversion + gcc -c include_a.c -wconversion -wsystem-headers in file included dir/a.h:1:0, include_a.c:1: ./b.h: in function ‘f’: ./b.h:1:31: warning: conversion ‘char’ ‘int’ may alter value [-wconversion] void f() {int = 0; char b = a;} ^ + gcc -c include_b.c -wconversion in file included include_b.c:1:0: b.h: in function ‘f’: b.h:1:31: warning: conversion ‘char’ ‘int’ may alter value [-wconversion] void f() {int = 0; char b = a;} ^
this behavior seems not bug because gcc , clang perform in same way, how can obtain warnings source files?
Comments
Post a Comment