Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 785929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:57:23+00:00 2026-05-14T20:57:23+00:00

What are the best strategies for finding that missing semicolon that’s causing the error?

  • 0

What are the best strategies for finding that missing semicolon that’s causing the error? Are there automated tools that might help.

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

Background:
Presently I have a particularly elusive missing semicolon (or brace) in a C++ program that is causing a C2143 error. My header file dependencies are fairly straightforward, but still I can’t seem to find the problem. Rather than post my code and play Where’s Wally (or Waldo, depending on where you’re from) I thought it would be more useful to get some good strategies that can be applied in this and similar situations.

As a side-question: the C2143 error is showing up in the first line of the first method declaration (i.e. the method’s return type) in a .cpp file that includes only its associated .h file. Would anything other than semicolons or braces lead to this behaviour?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:57:23+00:00Added an answer on May 14, 2026 at 8:57 pm

    It’s unlikely to be a missing semicolon, except (as @Michael suggested) from the end of a class. Generally a missing semicolon causes an error within a line or two.

    If it’s a scope brace then it’s usually not too far away, although sometimes they can be a long way off..

    Backtrack from the error line (go backwards up the code, and then backwards through each include from the bottom one), checking the braces. Chances are it’s at the start of your cpp file just prior to the site of the error, or the end of the last include, so that’s the best place to start.

    You can use various techniques:

    • Just read the code. If you follow a clean symmetrical coding style a missing brace will often slap you in the face. (You can use Edit->Advanced->Format Document to tidy up code if it is in an inconsistent style).

    • Place the cursor on each end of scope } and press ctrl+} to take the cursor to the matching brace. This will either do nothing, in which case there is no match, or will jump to the match and you can check that it is the correct brace.

    • If you have a lot of code to consider, just comment a lot of it out with #if FALSE. You’ll get different compiler errors, but if the original error stays you know it’s not caused by the commented code, and you can move on to the next include/class/block.

    • The worst case scenario is that it’s some code in a macro. If you have added/edited/used any macros in the last day, then check them first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What are the best approaches to implementing monads in C#? Are there particular implementation-strategies
I was wondering if people would share their best practices / strategies on handling
I formerly asked for a Best-Practice regarding this, But this is one the strategies
Best practices or tools for installing a SQL Server database I have a SQL
I am looking for strategies, best practices and solutions to adding a custom class
When fixing defects in new code what are the best strategies to use? cause
My application will have different strategies for my objects. What is the best way
what are best strategies to group classes in packages e.g. all managers in one
My system was mentioned in this question: https://stackoverflow.com/questions/5633634/best-index-strategies-for-read-only-table because the data is readonly, and
What is best strategy of protecting from registration bots. Ones that just POSTing registration

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.