19

How does one get gcc to not stop compiling after the first error. Is there a compiler flag that will do this?

Basically I'm wanting to remove a class, but i'm not sure how much of an impact that will have, so i'm wanting to determine how many classes would have provblems if i, say, remove the class from the makefile.

Is there a better way to determine this impact?

shadonar
  • 1,114
  • 3
  • 16
  • 40

2 Answers2

34

There's a GCC compiler option -Wfatal-errors to stop after the first error:

-Wfatal-errors
This option causes the compiler to abort compilation on the first error occurred rather than trying to keep going and printing further error messages

You can also use -Werror if you want to treat warnings as errors so that you'll catch any warning that might be generated when you remove your class.

P.P
  • 117,907
  • 20
  • 175
  • 238
  • I'm confused. Adding `-Wfatal-errors` says it does the exact opposite of what the OP asks: `-Wfatal-errors` will cause it TO STOP on the first error, but the OP asks how to make it NOT stop on the first error. – Gabriel Staples Jun 26 '21 at 19:51
  • 1
    @GabrielStaples Indeed! My guess is that OP has `-Wfatal-errors` so removing it solved it (it can be explicitly set as well via `-Wno-fatal-errors` in case removing `-Wfatal-errors` isn't possible/desireable but a temp solution is needed). – P.P Aug 09 '21 at 15:43
0

Is there a better way to determine this impact?

Use the refactoring support, built-in in many IDEs. For example, with NetBeans, you can choose to rename a class and preview all affected places.

Without an IDE, you can rename the class/method/field, instead of deleting it and gradually, with several compilation runs, change all usages of the old name, where the compiler gives an error. Then grep for the new name.

chill
  • 16,470
  • 2
  • 40
  • 44