Edit: you can make specific warnings being treated as errors in GCC/Clang, with this flag: -Werror=<warning name>
.
You can treat warnings as errors in GCC (or Clang), by using the -Werror
flag. Other compilers have their own respective flags.
Then, you would get something like this:
prog.c: In function 'doStuff':
prog.c:4:17: error: unused parameter 'pA' [-Werror=unused-parameter]
4 | void doStuff(A* pA) {};
| ~~~^~
prog.c: In function 'main':
prog.c:8:12: error: passing argument 1 of 'doStuff' from incompatible pointer type [-Werror=incompatible-pointer-types]
8 | doStuff(&b);
| ^~
| |
| B * {aka struct B *}
prog.c:4:17: note: expected 'A *' {aka 'struct A *'} but argument is of type 'B *' {aka 'struct B *'}
4 | void doStuff(A* pA) {};
| ~~~^~
cc1: all warnings being treated as errors
Live Demo