liaquore
liaquore

Reputation: 397

Visual Studio 2019 C++ - incorrectly reporting errors when compiling

I'm using Visual Studio 2019 to make a shared library using C++ and when I try to compile my project a bunch of errors come up that do not appear in the code via red jagged underlines. Some of the errors are actual errors (which has mostly been forgetting to forward-declare classes) but others do not make any sense. I got one that says ';' goes before '*' on this line:

static Game* gameInst; // this is inside a class definition

The line above is not missing a semi-colon either. I also get a bunch of other errors that make no sense, such as claiming a parameter to a constructor is not defined, even though it is a variable defined in the parameters of the constructor. Is my C++ installation/Visual Studio broken? Has anyone else had this issue? Any help is appreciated.

Upvotes: 0

Views: 845

Answers (1)

selbie
selbie

Reputation: 104579

Is my C++ installation/Visual Studio broken

No, your Visual Studio install is fine. Everything you describe is normal for C++ and IDEs.

When I try to compile my project a bunch of errors come up that do not appear in the code via red jagged underlines. Some of the errors are actual errors (which has mostly been forgetting to forward-declare classes) but others do not make any sense.

Fix your compiler errors in the order listed. Start with the first reported error in the build output before fixing errors reported after it. It's not unusual for an error occurring on a single line to generate dozens of subsequent errors that do make sense. When you encounter an an error in the list doesn't make sense, just try compiling again. Chances are high that the error goes away or a different error reveals itself as a result of fixing the issues that happened above it. Repeat this process until all compiler errors are resolved.

As for the red jagged underlines. Those are hints that something is wrong, but it's not always reliable. There are both false positives and missed errors in the IDE. When building and compiling your code, the compiler output is more accurate.

Upvotes: 3

Related Questions