I often build with -Wfatal-errors
because I don't need an extra 100 meaningless errors while the compiler heroically tries to parse the rest of a source file after a typo that renders it meaningless.
However, I've noticed that this also turns off diagnostic notes about the fatal error itself. For instance, with -Wfatal-errors
I will get, say,
main.cpp:10:2: error: invalid new-expression of abstract class type 'C'
new C();
whereas if I don't have -Wfatal-errors
on, I will get a note telling me which virtual method I forgot to implement:
class.hpp:15:2 note: because the following virtual functions are pure within 'C':
class.hpp:28:6 void C::f()
Can I get these notes back while still keeping the behavior where I terminate after a single error?
You're looking for -fmax-errors=1
. This will terminate compilation after the first error, but still show the notes for that error.
Here's a demo to compare the effects of these flags.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.