c++ - The purpose of stdafx.h (And: Why doesn't this work?) -


i working on project has vendor-provided api. i've made class uses api in project , i've included vendors header file in stdafx.h file. things not compile.

i put #include directly class' header file , things compile (and yes, class includes stdafx.h isn't reason.

do of have guesses why wouldn't compile first time around? isn't project-stopper far i'd prefer if keep vendor api files in stdafx.h belong.

edit: problem solved, i'd created cyclic dependency forgetting #ifndef header file , including them in wrong order. feel idiot.

stdafx.h used in vs generated projects 'container' of headers precompiled.

when added new #include stdafx.h didn't included because project configured use precompiled headers, , when add stdafx.h need regenerate .pch file contains precompiled information.

one way have .cpp file in project nothing #include "stdafx.h". maybe call `precompile.cpp". go project settings for 1 .cpp file , change following setting (for configurations):

"c/c++ | precompiled headers | precompiled header" setting  

and select "create /yc".

that set build when precompile.cpp needs built (because stdafx.h header includes has changed), it'll rebuild .pch file else uses.


Comments

Popular posts from this blog

jQuery Ajax Render Fragments OR Whole Page -

javascript - Iterate over array and calculate average values of array-parts -

java - Simple Command Line calculator -