Ignoring a file in a solution

Posted on 2009-04-28
Last Modified: 2013-11-20

I have a cpp file which is in a solution in Visual Studio 2008 which I use as a temporary area for me to write development code. As such the code isn't always in a compilable state.

Because of this, when I compile, I get loads of errors from this file.

Is there a way for me to tell the compiler to ignore the code in the file? The way I'm doing this at the moment is to just comment all the code but I don't really want to do this.

Is there a declaration I can use to tell the compiler to ignore all the code in the file?

Question by:IssacJones
    LVL 19

    Accepted Solution

    On solution explorer right click on the file and choose properties.
    Select "Exclude from compilation" : yes
    LVL 30

    Expert Comment

    Hi IssacJones,

    you can either exclude the file from build (right click at the file in the solution tree, Properties from context menu, set 'Excllude from build' to 'yes'.

    Or you can simply encapsulate the code you don't want to be compiled with a #if/endif like this:

    > #if 0
    > You can write here what you want ...
    > #endif

    Hope that helps,

    LVL 30

    Expert Comment

    Sorry, alb66 ...
    LVL 4

    Expert Comment


    you can put a /* to the top and a */ to the bottom


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
    Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now