views:

46

answers:

3

When working in VS, the error messages in the bottom panel are compiler errors and warnings, right? Does this mean the app is being compiled all the time? I would expect those to appear only when trying to run the app.

This is probably a silly question, but I cannot find the answer.

A: 

When you compile an application there might be errors and warnings which will be shown at the errors window. When you run the application errors will no longer be shown in Visual Studio but depending on how your application is organized it will either crash or handle them gracefully. Also notice that if you try to run the application with F5 or Ctrl+F5 Visual Studio will try to compile it first and if there are compile-time errors and warnings they will be shown.

Darin Dimitrov
I know..but it is displayed while writing the code, not only after running it.
Leberian
The code editor might underlines errors in your source code while typing as it analyzes it constantly.
Darin Dimitrov
+3  A: 

Visual Studio continually parses the source code; this allows it to preemptively report some errors before you actually compile the source.

This is, of course, dependent upon which language you are using. C++ didn't get preemptive error reporting until Visual Studio 2010.

James McNellis
Thanks. I know it parses the code but I am not sure whether other things like e.g. wrong types errors are not rather result of compilation
Leberian
@Leberian: Well, after the source is parsed, basic semantic analysis is performed to check for some errors like that. I don't know exactly what all is checked. It isn't a full compilation from source to binary, though.
James McNellis
A: 

Each programming language is different (each provides a Visual Studio 'language service' specific to that language that provides the feedback), but for the most part, yes, it is being compiled over and over. In F#, for example, the compiler is divided into a few stages, main ones being lexer/parser, typechecker, and code generator, and the lexer/parser/typechecker are running inside VS, and every time you type a character into a file, that file is re-run through those stages of the compiler.

Brian