Skip to content

Commit 88fad06

Browse files
committed
Add pragma value to disable GCC warnings altogether
This is useful for generated files such as those produced by the protocol buffers compiler.
1 parent 2642028 commit 88fad06

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

GNUmakefile

+20-7
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,20 @@ NULL := # useful for terminating lists of files
7373
# The optional third parameter $(3) is any additional options compiler options.
7474
define run-cc
7575
@GCCWARN=$$( $(PRAGMAS) -q GCCWARN $(2) ); \
76-
if [ $$GCCWARN -eq 5 ]; then \
76+
case $$GCCWARN in \
77+
0) \
78+
echo $(CC) $(CFLAGS_BASE) $(3) -c -o $(1) $(2); \
79+
$(CC) $(CFLAGS_BASE) $(3) -c -o $(1) $(2); \
80+
;; \
81+
5) \
7782
echo $(CC) $(CFLAGS_NOWERROR) $(3) -c -o $(1) $(2); \
7883
$(CC) $(CFLAGS_NOWERROR) $(3) -c -o $(1) $(2); \
79-
else \
84+
;; \
85+
9) \
8086
echo $(CC) $(CFLAGS) $(3) -c -o $(1) $(2); \
8187
$(CC) $(CFLAGS) $(3) -c -o $(1) $(2); \
82-
fi
83-
88+
;; \
89+
esac
8490
endef
8591

8692
# run-cxx:
@@ -91,13 +97,20 @@ endef
9197
# The optional third parameter $(3) is any additional options compiler options.
9298
define run-cxx
9399
@GCCWARN=$$( $(PRAGMAS) -q GCCWARN $(2) ); \
94-
if [ $$GCCWARN -eq 5 ]; then \
100+
case $$GCCWARN in \
101+
0) \
102+
echo $(CXX) $(CXXFLAGS_BASE) $(3) -c -o $(1) $(2); \
103+
$(CXX) $(CXXFLAGS_BASE) $(3) -c -o $(1) $(2); \
104+
;; \
105+
5) \
95106
echo $(CXX) $(CXXFLAGS_NOWERROR) $(3) -c -o $(1) $(2); \
96107
$(CXX) $(CXXFLAGS_NOWERROR) $(3) -c -o $(1) $(2); \
97-
else \
108+
;; \
109+
9) \
98110
echo $(CXX) $(CXXFLAGS) $(3) -c -o $(1) $(2); \
99111
$(CXX) $(CXXFLAGS) $(3) -c -o $(1) $(2); \
100-
fi
112+
;; \
113+
esac
101114
endef
102115

103116
define filter-pragma

pragmas.conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
magic_pattern = 'RAMCloud[\s_-]+pragma.*\[(.*)\]'
66

77
gccwarn = PragmaDefinition('GCC warnings', default=9)
8+
gccwarn[0] = 'no warnings'
89
gccwarn[5] = 'non-fatal warnings'
910
gccwarn[9] = 'fatal, pedantic warnings'
1011
definitions['GCCWARN'] = gccwarn

0 commit comments

Comments
 (0)