CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,867

    Precompiled header woes

    I've long been hugely suspicious of precompiled headers and always turn them off whenever possible. The biggest problem is that if you modify a header file, the compiler doesn't seem to rebuild the pch. Therefore any code you want to recompile simply carries on using the unmodified version of the header code. This doesn't seem to be confined to Visual C++. Other compilers seem to behave in the same way.

    Firstly, is there any way to force a precompiled header to be rebuilt when a relevant header file changes?

    Secondly, when you select precompiled headers in the project settings, what exactly is the meaning of the field called "through header". EG some sample programs that I've seen are designed to use precompiled headers "through header stdafx.h". What exactly does this mean??

    Thanks,

    John E

  2. #2
    Join Date
    Apr 1999
    Location
    Altrincham, England
    Posts
    4,470
    I've never had that problem - but then, I try to avoid putting changeable headers in stdafx.h. In fact, my philosophy is to not touch stdafx.h after Visual Studio has created it (unless it's to add in a non-default MFC header).

    Secondly, when you select precompiled headers in the project settings, what exactly is the meaning of the field called "through header". EG some sample programs that I've seen are designed to use precompiled headers "through header stdafx.h". What exactly does this mean??
    It means that the compiler basically ignores everything until it sees '#include "stdafx.h"'. This has been the cause of a number of problems for novices who put code above that line and then can't figure out why they get errors.
    Correct is better than fast. Simple is better than complex. Clear is better than cute. Safe is better than insecure.
    --
    Sutter and Alexandrescu, C++ Coding Standards

    Programs must be written for people to read, and only incidentally for machines to execute.

    --
    Harold Abelson and Gerald Jay Sussman

    The cheapest, fastest and most reliable components of a computer system are those that aren't there.
    -- Gordon Bell


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured