Simplest way
It looks like you can call
gcc -c ... -Werror ... -Wno-error ...
without GCC filing (GCC 4.7.1). That way, you can add -Wno-error to CFLAGS created elsewhere in the makefile where you need it. If you use GNU make , in one makefile you can add:
CFLAGS += -Wno-error
possible only for the only purpose that he needs.
Harder way
Otherwise, you will need a system to create CFLAGS from components. What I have in the makefile that I use to test answers to questions on SO:
WFLAG1 = -Wall WFLAG2 = -Wextra WFLAG3 = -Wmissing-prototypes WFLAG4 = -Wstrict-prototypes WFLAG5 = -Wold-style-definition WFLAG6 = WFLAGS = ${WFLAG1} ${WFLAG2} ${WFLAG3} ${WFLAG4} ${WFLAG5} ${WFLAG6} SFLAGS = -std=c99 GFLAGS = -g OFLAGS = -O3 UFLAGS = IFLAG1 = -I${HOME}/inc IFLAGS = # ${IFLAG1} CFLAGS = ${OFLAGS} ${GFLAGS} ${IFLAGS} ${SFLAGS} ${WFLAGS} ${UFLAGS}
The main thing is that each flag is independently configured; I can control the warning flags by setting any of ${WFLAG1} to ${WFLAG6} , or by setting the ${WFLAGS} option on the command line or (really) by setting ${CFLAGS} . But since each of them is individually configurable and can easily configure alerts (the main problem is determined by which WFLAGn needs to be knocked down).
UFLAGS are "user flags" and are set only on the command line; I can add more flags to my command line by setting it.
This method is more complicated because it requires changing the central part of your makefile system where you install CFLAGS. It is also less likely that your peers are clear at a glance.
Jonathan leffler
source share