Reputation: 38270
Is it possible to 'tell' compiler that if total number of warnings (while compiling a C++ program) are more than say 10 then stop compiling further, and emit an error? Or is it possible to hack a compiler like clang to provide this functionality.
Upvotes: 1
Views: 970
Reputation: 71
GCC has two options together would achieve this, from gnu online docs:
-Werror
Make all warnings into errors.-fmax-errors=n Limits the maximum number of error messages to n, at which point GCC bails out rather than attempting to continue processing the source code.
This would make a build with any warnings fail though, the options just define when to stop parsing.
Upvotes: 4
Reputation: 52395
How about using -Werror
to make warnings into errors and -fmax-errors=n
to set the limit.
(Also, perhaps making your code completely warning free would be a good thing).
Upvotes: 3
Reputation: 59841
I haven't seen this kind of feature in gcc or clang. You can certainly try to patch it into either of them, both are open source. There is also -Werror
(accepted by both compilers) which simply treats warnings as errors.
Upvotes: 2