Project compiles but VS IDE shows red error lines
-
Hello there. I have this project which compiles fine but VS IDE shows that it can not find identifier. Under these identifiers are red lines. WHY is it so ??? Is there some setting I need to check??
This world is going to explode due to international politics, SOON.
-
Hello there. I have this project which compiles fine but VS IDE shows that it can not find identifier. Under these identifiers are red lines. WHY is it so ??? Is there some setting I need to check??
This world is going to explode due to international politics, SOON.
It is only the VS tool Intellisense that produces the red lines. Intellisense is not as clever as the compiler, so it may have trouble identifying some symbols. This is less of an issue in newer versions of VS (you didn't say which version you have), but it can still happen in code that requires multiple passes to interpret, e. g. code involving
#define
macros and/or templates.GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
Hello there. I have this project which compiles fine but VS IDE shows that it can not find identifier. Under these identifiers are red lines. WHY is it so ??? Is there some setting I need to check??
This world is going to explode due to international politics, SOON.
-
It is only the VS tool Intellisense that produces the red lines. Intellisense is not as clever as the compiler, so it may have trouble identifying some symbols. This is less of an issue in newer versions of VS (you didn't say which version you have), but it can still happen in code that requires multiple passes to interpret, e. g. code involving
#define
macros and/or templates.GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
I am using VS Ultimate 2013.
Stefan_Lang wrote:
but it can still happen in code that requires multiple passes to interpret
Did you mean compile ? If not, what do you mean by
multiple passes to interpret
??This world is going to explode due to international politics, SOON.
-
I am using VS Ultimate 2013.
Stefan_Lang wrote:
but it can still happen in code that requires multiple passes to interpret
Did you mean compile ? If not, what do you mean by
multiple passes to interpret
??This world is going to explode due to international politics, SOON.
I meant interpret in the sense to figure out what a line of code means. Maybe analyze is a better term. Both the compiler and Intellisense need to do this, although for the compiler that's just an intermediate step. E. g. in a first pass, all preprocessor commands are interpreted, such as #include, #define, and #pragma. After that, most of the code should be plain C/C++, except template definitions: template code is not complete until you specify the template arguments, and that may only happen much later in the code, or, possibly, not at all in the current compilation unit. The purpose of Intellisense (or one of its purposes) is to give you instant feedback on the correctness of code as you type. But it can't give you that feedback for code that requires other code from an entirely different part of the solution.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
-
I am using VS Ultimate 2013.
Stefan_Lang wrote:
but it can still happen in code that requires multiple passes to interpret
Did you mean compile ? If not, what do you mean by
multiple passes to interpret
??This world is going to explode due to international politics, SOON.
The underlining is done by the editor which is part of the IDE. It parses the source files and tries to find the definitions of variables, functions etc., in the source file itself and the included files. Stefan called this process "interpretation". The parser (the part of the IDE that does this job) is not a compiler. But it is somewhat similar to a compiler by performing identical or similar tasks to check the source code. A compiler processes his input files not in one go but uses multiple "passes". The parser might not do this or might not perform always similar to a compiler. This may then lead to the behaviour you are seeing.