Share via


Walkthrough: Building a Project (C++)

In this step, you deliberately introduce a Visual C++ syntax error in your code to see what a compilation error looks like and how to fix it. When you compile the project, an error message indicates what the problem is and where it occurred.

Prerequisites

This topic assumes that you understand the fundamentals of the C++ language.

Note

If you are using Visual C++ Express 2010 with Basic Settings, your menu bar and menu choices are simplified. On the menu bar, choose Tools, Settings, Expert Settings to see the full menus.

To fix compilation errors using the IDE

  1. In testgames.cpp, delete the semicolon in the last line so that it resembles this:

    return 0
    
  2. On the menu bar, choose Build, Build Solution to build the project. (If you are using Visual C++ Express 2010 with Basic Settings, choose Debug, Build Solution.)

  3. A message in the Output window indicates that building the project failed.

    In the Output window, choose the Go To Next Message button (the icon that has a green, right-pointing arrow) to highlight the error message. The error message in the Output window and status bar area indicates there is a missing semicolon before the closing brace:

    error C2143: syntax error : missing ';' before '}'

    To view more help information about an error, highlight the error in the Output window and then choose the F1 key.

  4. Add the semicolon back to the end of the line with the syntax error:

    return 0;
    
  5. On the menu bar, choose Build, Build Solution. (If you are using Visual C++ Express 2010 with Basic Settings, choose Debug, Build Solution.)

    A message in the Output window indicates that the project compiled successfully.

    1>------ Build started: Project: Game, Configuration: Debug Win32 ------
    

1> TestGames.cpp 1> Game.vcxproj -> c:\users\username\documents\visual studio 2010\Projects\Game\Debug\Game.exe ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Next Steps

Previous: Walkthrough: Working with Projects and Solutions (C++) | Next: Walkthrough: Testing a Project (C++)

See Also

Tasks

Visual C++ Guided Tour

Other Resources

Building and Debugging