Thread: Precompiled Headers, are they necessary?

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    31

    Precompiled Headers, are they necessary?

    When I created my project / workspace in Visual C++ 6, it automatically created this file:

    StdAfx.h

    All it had in it was this:

    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    //

    #if !defined(AFX_STDAFX_H__DC3CC640_9ABC_42A1_9B37_1C9 3035F4806__INCLUDED_)
    #define AFX_STDAFX_H__DC3CC640_9ABC_42A1_9B37_1C93035F4806 __INCLUDED_

    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000


    // TODO: reference additional headers your program requires here

    //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.

    #endif // !defined(AFX_STDAFX_H__DC3CC640_9ABC_42A1_9B37_1C9 3035F4806__INCLUDED_)
    VC also automatically created my project's .cpp file and at the top it had:

    #include "stdafx.h"

    Yes, with quotes instead of <>.

    Anyway, I put all my #include statements in my project's .cpp file and commented out the include line. Also, under project / settings I changed the option "Precompiled Headers" on the C++ tab to "Not using Precompiled Headers" and everything worked fine.

    So is this precompiled header thing really necessary? Or, what is / isn't the benefit of having one?

    Thanks,

    Xeno
    Welcome to the funhouse, where strange mirrors reflect the faces of insanity.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    For bare SDK applications or console based nonsense I dont ever let VC create the files - I prefer to work from my own templates....

    But for MFC & ATL I assume this stuff is important, and as both of these are heavily reliant on stuff the compiler does for you, I leave them in....

  3. #3
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    U include files that will not change or barely will...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Precompiled header question
    By donglee in forum C++ Programming
    Replies: 13
    Last Post: 01-22-2009, 01:23 AM
  2. How to use precompiled headers in GCC?
    By jutirain in forum C++ Programming
    Replies: 0
    Last Post: 02-04-2008, 10:19 PM
  3. Precompiled headers
    By rokenrol in forum C Programming
    Replies: 2
    Last Post: 04-07-2007, 01:21 AM
  4. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04:25 AM
  5. Precompiled Headers
    By Bazz in forum C++ Programming
    Replies: 2
    Last Post: 02-12-2002, 08:57 AM