I want to create a .pch within a make file. cl /nologo /c /YcPrecompiled.hpp /FpPrecompiled.pch Precompiled.cpp
What confused me is : Why this command also create a object named Precompiled.obj
Should I link this object to the finale exe?
After I search on the web, I found a tutorial on msdn: http://msdn.microsoft.com/en-us/library/d9b6wk21(v=VS.71).aspx I cann't understand one line:
$(CPP) $(CLFLAGS) /Yc$(BOUNDRY) applib.cpp myapp.cpp
When creating a pch, why does it need applib.cpp and myapp.cpp. And It also create two objects, applib.obj, myapp.obj, except the .pch file....Why?
Any indication is welcomed. Thanks very much!
MSDN does mention it at least in other 2 places:
STDAFX.CPP, STDAFX.H : These files are used to build a precompiled header file PROJNAME.PCH and a precompiled types file STDAFX.OBJ.
This description indeed doesn't clearly distinguish between precompiled header and precompiled types. Running dumpbin on a typical stdafx.obj from an MFC project, you'd see it contains a whole bunch of static ATL types, whose definition is buried somewhere deep in the include tree:
...
COMDAT; sym= "struct ATL::IAtlAutoThreadModule * ATL::_pAtlAutoThreadModule" (?_pAtlAutoThreadModule@ATL@@3PEAUIAtlAutoThreadModule@1@EA)
COMDAT; sym= "public: static int const ATL::AtlLimits<int>::_Min" (?_Min@?$AtlLimits@H@ATL@@2HB)
COMDAT; sym= "public: static int const ATL::AtlLimits<int>::_Max" (?_Max@?$AtlLimits@H@ATL@@2HB)
COMDAT; sym= "public: static unsigned int const ATL::AtlLimits<unsigned int>::_Min" (?_Min@?$AtlLimits@I@ATL@@2IB)
COMDAT; sym= "private: static int (__cdecl* ATL::CNoUIAssertHook::s_pfnPrevHook)(int,char *,int *)" (?s_pfnPrevHook@CNoUIAssertHook@ATL@@0P6AHHPEADPEAH@ZEA)
COMDAT; sym= "public: static bool ATL::CAtlBaseModule::m_bInitFailed" (?m_bInitFailed@CAtlBaseModule@ATL@@2_NA)
COMDAT; sym= "public: static unsigned short const ATL::CVarTypeInfo<char>::VT" (?VT@?$CVarTypeInfo@D@ATL@@2GB)
COMDAT; sym= "public: static char tagVARIANT::* ATL::CVarTypeInfo<char>::pmField" (?pmField@?$CVarTypeInfo@D@ATL@@2QEQtagVARIANT@@DEQ3@)
COMDAT; sym= "public: static unsigned short const ATL::CVarTypeInfo<unsigned char>::VT" (?VT@?$CVarTypeInfo@E@ATL@@2GB)
...
Which kind of makes sense - if you define a static variable in a pch, there's no other reasonable place to put it in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With