Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to instruct GCC to stop after 5 errors?

Tags:

c++

gcc

g++

Is it possible to instruct GNU c++ compiler to stop after 5 errors found? Can't find this in documentation.

like image 419
yegor256 Avatar asked Jul 11 '10 16:07

yegor256


3 Answers

The command-line option -fmax-errors=N directs the compiler to give up after N errors. This option is present in GCC 4.6 and later.

The command-line option -Wfatal-errors directs the compiler to give up after one error. This option is present in GCC 4.0 and later.

In both cases, warnings do not count toward the limit unless you also specify -Werror.

like image 142
zwol Avatar answered Nov 19 '22 15:11

zwol


You can use gcc option:

-fmax-errors=5

for this purpose.

like image 34
user1993934 Avatar answered Nov 19 '22 15:11

user1993934


I would welcome such an option as well. For now, I'm using the following workaround to get the first five errors:

<make> 2>&1|grep error|head -5
like image 5
Tomasz Romanowski Avatar answered Nov 19 '22 15:11

Tomasz Romanowski