Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is C# compiler not reporting all errors at once at each compile?

When I am compiling this project, it show like 400+ errors in the Error List window, then I go to error sites, fix some, and the number goes to say 120+ errors, and then after fixing some more, the next compile reports like 400+ again. I can see that different files are coming in in the Error List window, so I am thinking the compiler aborts after a certain number of errors?

If so, what's the reason for this? Is it not supposed to gather all the errors that are present in the project even if they are over 10K+?

like image 800
Joan Venge Avatar asked Jan 14 '11 23:01

Joan Venge


People also ask

Is C+ Same as C?

C++ was developed by Bjarne Stroustrup in 1979. C does no support polymorphism, encapsulation, and inheritance which means that C does not support object oriented programming. C++ supports polymorphism, encapsulation, and inheritance because it is an object oriented programming language. C is (mostly) a subset of C++.

What is '~' in C programming?

In mathematics, the tilde often represents approximation, especially when used in duplicate, and is sometimes called the "equivalency sign." In regular expressions, the tilde is used as an operator in pattern matching, and in C programming, it is used as a bitwise operator representing a unary negation (i.e., "bitwise ...

Is C or C+ Better?

Compared to C, C++ has significantly more libraries and functions to use. If you're working with complex software, C++ is a better fit because you have more libraries to rely on. Thinking practically, having knowledge of C++ is often a requirement for a variety of programming roles.

Is there a C+?

C+ is a slightly above average grade on an assignment (usually within an educational context)... There is much debate on this topic... Low and High level languages: 1.


2 Answers

I've been meaning to write a blog article about this.

It is possible that you're simply running into some hard-coded limit for the number of errors reported. It's also possible that you're running into a more subtle and interesting scenario.

There are a lot of heuristics in the command-line compiler and the IDE compiler that attempt to manage error reporting. Both to keep it manageable for the user, and to make the compiler more robust.

Briefly, the way the compiler works is it tries to get the program through a series of stages, which you can read about here:

http://blogs.msdn.com/b/ericlippert/archive/2010/02/04/how-many-passes.aspx

The idea is that if an early stage gets an error, we might not be able to successfully complete a later stage without (1) going into an infinite loop, (2) crashing, or (3) reporting crazy "cascading" errors. So what happens is, you get one error, you fix it, and then suddenly the next stage of compilation can run, and it finds a bunch more errors.

Basically, if the program is so messed up that we cannot even verify basic facts about its classes and methods, then we can't reliably give errors for method bodies. If we can't analyze a lambda body, then we can't reliably give errors for its conversion to an expression tree. And so on; there are lots of situations where later stages need to know that the previous stages completed without errors.

The up side of this design is that (1) you get the errors that are the most "fundamental" first, without a lot of noisy, crazy cascading errors, and (2) the compiler is more robust because it doesn't have to try to do analysis on programs where the basic invariants of the language are broken. The down side is of course your scenario: that you have fifty errors, you fix them all, and suddenly fifty more appear.

like image 164
Eric Lippert Avatar answered Oct 21 '22 05:10

Eric Lippert


Of course it will stop at some point.

Even after 1 error, all the rest is dubious at best. A compiler will try to recuperate, but that's not guaranteed to succeed.

So in any non-trivial project, it's a practical decision between stopping at the first error (theoretically the best thing to do) and ploughing on in an unreliable state.

The most correct action would be to stop after 1 error, but that would lead to a tedious 'fix 1 at a time' situation. So a compiler tries to resync to a known state and report the next one. But an error could cause false errors in correct code following it, so at some point it stops being sensible.

Refer to your own case: 400+ goes to 120 after a few fixes.

like image 40
Henk Holterman Avatar answered Oct 21 '22 04:10

Henk Holterman