在 Visual C++ 中替换 #import [英] Replacement for #import in Visual C++
问题描述
我们有一个大型 C++ 项目,我们使用/MP 开关进行编译以利用多个内核.
We have large C++ project that we used to compile with the /MP switch to take advantage of multiple cores.
但是,我们最近引入了一些在几个 tlb 上使用 #import 的代码,而 #import 与/MP 不兼容,这意味着我们又回到了单线程构建,并且有更多的时间来喝咖啡.
However, we recently brought in some code that uses #import on a couple of tlb's, and #import is incompatibile with /MP, which means we are back to single threaded builds and a lot more time to get coffee.
关于如何让#import 和/MP 发挥出色的任何建议?是否有工具可以从 #import 作为预构建步骤静态生成 C++ 标头?
Any suggestions on how to get #import and /MP to play nice? Is there a tool that will statically generate the C++ headers from a #import as a pre-build step?
更新:
听从马特的建议效果很好.对于在谷歌中遇到这个问题的其他人:
Following Matt's advice worked great. For anyone else stumbling over this in google:
- 创建一个单独的静态库项目
- 设置足够的包含,以便您可以将
#import
语句放入 lib 项目中 - 使您的主项目依赖于 lib 项目(以确保正确的构建顺序)
- 将 lib 项目的临时构建文件夹添加到主项目的包含路径
#include
生成的.tlh
文件,您在其中执行#import
- 启用
/MP
开关并失去茶歇时间...
- create a separate static lib project
- set up enough includes so you can put the
#import
statement in the lib project - make your main project dependent on the lib project (to ensure correct build order)
- add the lib project's temporary build folder to the include path for the main project
#include
the generated.tlh
files where you were doing the#import
- enable the
/MP
switch and lose the coffee break time...
推荐答案
为什么不直接#include
从#import
生成的头文件?
Why not just #include
the generated headers created from #import
?
这篇关于在 Visual C++ 中替换 #import的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!