What is the most efficient way to find missing semicolons in VS with C ++?

What are the best strategies for finding the missing semicolon causing the error? Are there automatic tools that can help.

I am currently using Visual Studio 2008, but general strategies for any environment would be interesting and more useful.

Background: I currently have a particularly elusive missing semicolon (or parenthesis) in a C ++ program that causes error C2143. My dependencies in the header file are pretty simple, but still I cannot find the problem. Instead of publishing my code and playing where Wally (or Waldo, depending on where you come from), I thought it would be more useful to get good strategies that can be applied in this and similar situations.

As a side issue: error C2143 appears in the first line of the declaration of the first method (i.e. the type of the returned method) in the .cpp file, which contains only the associated .h file. Would something other than semicolons or braces lead to this behavior?

+3
source share
3 answers

This will probably be the missing semicolon except (as @Michael suggested) from the end of the class. Usually a missing semicolon causes an error in a line or two.

If this is a region bracket, then it is usually not too far, although sometimes they can be far.

( , ), . , cpp , , .

:

  • . , . ( Edit- > Advanced- > Format Document, , ).

  • } ctrl +}, . , , , , .

  • , #if FALSE. , , , , include/class/block.

  • - . // - , .

+1

? cpp. , " "; VS , , , , , ,

+5

Start with the line where the compiler told you that the error is on, and look at the code immediately preceding that line.

+3
source

Source: https://habr.com/ru/post/1745541/


All Articles