Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a normal compiler error and a fatal compiler error? [duplicate]

Tags:

c++

What is the main difference between fatal errors and non-fatal errors dipslayed in an IDE when one tries to compile the code?

In both cases the compiler shows an error message and the program is not compiled. Are fatal errors the undefined compiler errors in a compiler or linker?

like image 922
Minimus Heximus Avatar asked Aug 20 '14 09:08

Minimus Heximus


People also ask

What is the difference between compilation error and runtime error?

A compile-time error generally refers to the errors that correspond to the semantics or syntax. A runtime error refers to the error that we encounter during the code execution during runtime. We can easily fix a compile-time error during the development of code. A compiler cannot identify a runtime error.

What is difference between syntax error and compiler error?

Syntax errors are static error that can be detected by the compiler. Runtime errors are dynamic error that cannot be detected by the compiler.

What are the types of compilation errors?

There are 5 different types of errors in C programming language: Syntax error, Run Time error, Logical error, Semantic error, and Linker error. Syntax errors, linker errors, and semantic errors can be identified by the compiler during compilation.

What are the compiler errors?

Compilation error refers to a state when a compiler fails to compile a piece of computer program source code, either due to errors in the code, or, more unusually, due to errors in the compiler itself. A compilation error message often helps programmers debugging the source code.


3 Answers

A fatal error would probably stop compilation of that translation unit immediately.

A compiler may continue compiling after an error in order to reveal to you a more comprehensive list of issues.

Although in your case it appears that the preprocessor has issued the fatal error. Perhaps it's simply down to the mood of the compiler writer.

like image 124
Bathsheba Avatar answered Oct 13 '22 20:10

Bathsheba


The difference is this:

  • on a normal error, the compiler can continue its parsing, it's just a local problem (undeclared variable for instance, but the compiler knows how to recover from it. Some compilers go far in that process, adding missing ; and such)
  • on a fatal error, the compiler (or preprocessor) cannot possibly know how to continue (like it's "lost") because of a structural error (loses the context)

Which explains that sometimes you fix all your compiling errors, and new ones appear.

like image 32
Jean-François Fabre Avatar answered Oct 13 '22 19:10

Jean-François Fabre


The IDE is not the compiler. It generally starts another program (like GCC...) in command line to compile. Your IDE is simply a glorified editor (and on Linux the emacs editor is often better than an IDE).

Most compilers don't give fatal errors, except on compiler bugs, lacking resources at compile time, or when the source input cannot be further compiled: think of #include-ing a non existent header file.

BTW, sometimes a compiler gives so many errors (for instance, try to compile an English or French literature text disguised as a C file) that further compilation is meaning less.

like image 42
Basile Starynkevitch Avatar answered Oct 13 '22 18:10

Basile Starynkevitch