为什么在创建预编译头时也创建了对象?
我想在 make 文件中创建一个 .pch。 cl /nologo /c /YcPrecompiled.hpp /FpPrecompiled.pch Precompiled.cpp
让我困惑的是:为什么这个命令还创建一个名为 Precompiled.obj 的对象,
我应该将此对象链接到 Finale exe 吗?
我在网上搜索后,在msdn上找到了一个教程: http://msdn.microsoft.com/en-我们/library/d9b6wk21(v=VS.71).aspx 我无法理解一行:
$(CPP) $(CLFLAGS) /Yc$(BOUNDRY) applib.cpp myapp.cpp
创建 pch 时,为什么需要 applib.cpp 和 myapp.cpp。它还创建了两个对象,applib.obj,myapp.obj,除了 .pch 文件......为什么?
欢迎任何指示。 非常感谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您尝试在 makefile 中执行此操作,因此我会尝试遵循该教程中建议的模式(MSDN 中一直到 VS2010 都是相同的)。这就是 Microsoft 希望您在 makefile 中处理 PCH 生成的方式,是吗?
您这样做的方式并没有给您正确的结果 - 您不应该看到 PCH 的 OBJ 文件。让你的 makefile 与 Microsoft 模型相匹配,也许你会没事的。
关于需要在 makefile 的命令行中对文件进行编码以进行 PCH 编译 - 该教程的其他地方有更多的基本原理 这里。
Since you're trying to do this in a makefile, I would try following the pattern suggested in that tutorial (which is the same all the way up to VS2010 in MSDN). This is how Microsoft wishes you to handle PCH generation within makefiles, yes?
The way you are doing it is not giving you the right results - you should not see an OBJ file for the PCH. Make your makefile match the Microsoft model and maybe you will be OK.
Regarding the need to code files in the makefile's command line for PCH compilation - there is a bit more rationale elsewhere in that tutorial here.
MSDN 至少在 其他 2 地点:
这个描述确实没有明确区分预编译头和预编译类型。在 MFC 项目中的典型 stdafx.obj 上运行 dumpbin,您'我会看到它包含一大堆静态 ATL类型,其定义埋藏在包含树深处的某个地方:
哪种有意义 - 如果您在中定义静态变量一个电脑,没有其他合理的地方可以放置它。
MSDN does mention it at least in other 2 places:
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:
Which kind of makes sense - if you define a static variable in a pch, there's no other reasonable place to put it in.