Re: Putting #ifndef #endif around #include "StdAfx.h" causes problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Mihajlo Cvetanovic (mac_at_RnEeMtOsVeEt.co.yu)
Date: 01/18/05


Date: Tue, 18 Jan 2005 10:41:42 +0100

Doug Harrison [MVP] wrote:
> Mihajlo Cvetanovic wrote:
>
>>I actually put needed non-MFC #includes before stdafx so that everything
>>works in non-MFC non-pch projects. This makes sense only if the source
>>is non-MFC as well.
>
> Unless I'm missing something, it makes sense only if the source file in
> question is configured not to use precompiled headers. Otherwise, I expect
> your #includes will be ignored. I would try not to #include stdafx.h in that
> situation, because when I hear "stdafx.h", I think "precompiled headers".

Putting #includes before stdafx is a good way to inform a user (of a
source file) about what he needs to add to stdafx.h. Those #includes are
indeed ignored by compiler, but they're useful info for a user. Of
course a user should be familiar with the pch mechanism, since it won't
compile if some #include is missing in stdafx.h.

If a user does not use pch then she would just create dummy stdafx. Simple.



Relevant Pages

  • Re: Where is main?
    ... compiler that I am using, the source file of the form is almost empty, but ... what I am missing. ... I am sure there is some kind of philosophy out there ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Shared file only builds once
    ... I have a source file which is shared by two projects. ... The problem I have is that the project that is linking to the file doesn't appear to compile it with it's compiler options defined, but seems to use the object file of the other project. ... Am I missing something obvious or is there a problem with this? ... Paul ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Next project, C programming problem.
    ... > SAMBA does. ... But all the files are missing all the CR's and the compiler ... a couple of blocks of the source file, ...
    (comp.os.vms)
  • Re: How to set my own program startup in f77 programs other than MAIN__
    ... But we don't have the source file where ... whatever they call it these days) compiler. ... I think the whole approach of stuffing your initializer into a ... "Operation of the Runtime Linker ...
    (comp.lang.fortran)
  • Re: Why does VB6 always ask to save project with some projects?
    ... With a C IDE we open a source file in an editor. ... the editor is replaced with a compiler that takes ... immediately converted to opcode. ...
    (microsoft.public.vb.general.discussion)