Want to turn off "note" level messages in GCC

When I compile a C (no pluses) program using GCC, there are several levels of messages possible, like warning, error, and note. The note messages are useless and distracting. How do I make them go away using the command line? (I don’t use any sort of IDE.)

Example: /home/user/src9/AllBack3.c:129:9: note: each undeclared identifier is reported only once for each function it appears in.

Asked By: Jennifer

||

Pass the -fcompare-debug-second option to gcc.


gcc’s internal API has a diagnostic_inhibit_note() function which turns any "note:" messages off, but that is only serviceable via the unexpected -fcompare-debug-second command line switch, defined here.

Fortunately, turning notes off is its only effect, unless the -fcompare-debug or the -fdump-final-insns options are also used, which afaik are only for debugging the compiler itself.

Answered By: mosvy

You can use -w which also suppresses warnings.

For GCC, -w will not suppress the note you mentioned, probably because it is shown instead of another error. clang’s -w on the other hand suppresses that too.

Answered By: V13
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.