在 VC 中使用 MSBuild++ 2010 对文件进行自定义预处理

发布于 2024-11-05 23:26:18 字数 162 浏览 1 评论 0原文

我试图在常规预处理器完成后将自定义预处理器插入到 VC++ 2010 构建管道中,到目前为止,我认为这样做的方法是通过 MSBuild。

到目前为止,我无法找到更多信息,所以我的问题是:

  • 这可能吗?
  • 如果是这样,我需要看什么才能开始。

I am trying to insert a custom preprocessor into the VC++ 2010 build-pipe after the regular preprocessor has finished, so far i figured that the way of doing this is via MSBuild.

To this point I wasn't able to find out much more, so my questions are:

  • Is this possible at all?
  • If so, what do I need to look at, to get going.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见 2024-11-12 23:26:18

如果您谈论的是 c/c++ 预处理器,那么您可能不走运。 AFAIK,预处理器内置于编译器本身中。您可以让编译器输出预处理的文件,然后您可以再次通过编译器发送该文件以获得最终输出。

无论如何,这可能不起作用,因为生成的代码(至少在以前版本的 cl.exe 中)似乎不是 100% 正确(空格稍微被破坏,这可能会导致错误)。

如果您想走这条路,您需要做的是让 MSBuild“目标”在“ClCompile”目标之前运行。
这个新目标必须运行“cl.exe”程序,并使用“ClCompile”通常发送的所有设置以及“/P”选项,该选项将“预处理到文件”。
然后,您需要在处理后的文件上运行工具,最后将这些新文件输入“ClCompile”。

如果您需要更多信息,只需在评论中回复,我会在有时间时尝试添加一些信息(这个问题相当老了,所以我不确定是否值得在这个答案上投入更多时间)。

If you are talking about the c/c++ preprocessor, then you are probably out of luck. AFAIK, the preprocessor is built into the compiler itself. You can get the compiler to output a pre-processed file and then you MIGHT be able to send that through the compiler a second time to get the final output.

This may not work anyway due to the code being produced, at least in previous versions of cl.exe, doesn't seem to be 100% correct (white space gets mangled slightly which can cause errors).

If you want to take this path, what you'd need to do is have an MSBuild 'Target' that runs before the 'ClCompile' target.
This new target would have to run the 'cl.exe' program with all the settings that 'ClCompile' usually sends it with as well as the '/P' option which will "preprocess to a file".
Then you need to run your tool over the processed file and then finally feed these new files into 'ClCompile'.

If you need any more info just reply in the comments and I'll try to add some when I get the time (this question is rather old, so i'm not sure if it's worthwhile investing more time into this answer).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文