Thread: PRECOMPILED_CXX - why do we use this option?

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    19

    Smile PRECOMPILED_CXX - why do we use this option?

    Hi,

    At my work, I saw bunch of other projects doing PRECOMPILED_CXX=1 in their corresponding source configuration files.

    I searched on MSDN, and it gave me the following information.
    This macro definition indicates whether the associated precompiled header will be used with files written in C or C++.
    I have a program written in C++, but I forgot to put the PRECOMPILED_CXX=1 in the build settings, but it compiled fine, and then worked fine. So what exactly is the reason why we should set this macro when building C++ project?
    Code:
    # My source configuration file
    ...
    PRECOMPILED_INCLUDE=pch.h
    ...
    Another interesting thing I noticed. When I don't set the macro, the compiler won't complain when I only include pch.h in .h files and not in their corresponding .cpp files. But it will complain as expected when I set the macro. Does it have to do with C vs C++ pre-compiled header usage? I am just beginning to learn C/C++ build settings, so any help would be appreicated!
    Last edited by donglee; 04-06-2009 at 12:27 PM.

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by donglee View Post
    I have a program written in C++, but I forgot to put the PRECOMPILED_CXX=1 in the build settings, but it compiled fine, and then worked fine. So what exactly is the reason why we should set this macro when building C++ project?
    Because the documentation says so. It might work now, but could break in the future.

    Do not taunt the MS build!
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  2. Replies: 3
    Last Post: 12-06-2008, 07:54 PM
  3. For some reason I end up with memory leak...
    By RaDeuX in forum C Programming
    Replies: 10
    Last Post: 11-26-2008, 12:43 AM
  4. Memory Leak
    By jtullo in forum C Programming
    Replies: 7
    Last Post: 12-11-2006, 11:45 PM
  5. Binary Search Tree
    By penance in forum C Programming
    Replies: 4
    Last Post: 08-05-2005, 05:35 PM