如何在 Pre-Build... 中修改源文件而不修改源文件?
因此,我使用 Visual Studio 2005,并且对于我当前的项目,我正在构建一个 C# 插件来处理 AspectC++ 的方面编织。 收集方面和源文件并将它们输入方面编译器非常简单,但这会生成新的(修改后的)源文件。 我正在尝试模拟标准 AspectC++ 插件: http ://www.pure-systems.com/AspectC_Add-In.22+M54a708de802.0.html,所以当我将编织文件输入到C++编译器。 假设我什至可以做到这一点(不知道如何),我如何让调试器正确指向原始源文件? 我知道我必须取消选中 VS 选项,以便源代码不必与编译版本匹配,但我不知道如何在不直接修改源文件的情况下将两者关联起来。 有什么建议吗?
so I'm using Visual Studio 2005 and for my current project I'm building a C# Add-In to handle the weaving of aspects for AspectC++. It's simple enough to gather the aspect and source files and feed them into the aspect compiler, but this generates new (modified) source files. I'm trying to emulate the standard AspectC++ Add-In: http://www.pure-systems.com/AspectC_Add-In.22+M54a708de802.0.html, so I'd like to leave the source files for the project unchanged as I feed in the woven files to the C++ compiler. Assuming I can even do this (not sure how), how would I get the debugger to point correctly to the original source files? I know that I'll have to uncheck the VS option so the source doesn't have to match the compiled version, but I'm at a loss for how to associate the two without modifying the source files directly. Any advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您想在预处理器之前或之后修改源代码。 在这种情况下,您应该使用 #line 指令,告诉编译器它真正处理的文件和行。 这就是预处理器的工作方式,它将所有头文件包含到一个大文件中,该文件包含 #line 指令,这使得编译器能够报告正确行的错误,并在调试器的符号中指定正确的行。
您应该尝试仅在源文件上运行预处理器。 这将向您展示 #line 指令的工作原理。 cl.exe 命令行选项 /P 将为您提供帮助。 请记住,您将需要编译文件所需的所有其他预处理器选项,例如 /D 和 /I 才能正常工作。
http://msdn.microsoft.com/en-us /library/b5w2czay(VS.71).aspx
It sounds like you want to modify the source code just before or after the preprocessor. In this case you should use the #line directive, to tell the compiler what file and line it is really processing. This is how the preprocessor works, it includes all your header files into one massive file, this file contains #line directives, which enables the compiler to report errors for the correct line and specify the correct line in the symbols for the the debugger.
You should try just running the preprocessor on a source file. This will show you how the #line directive works. The cl.exe command line option /P will help you here. Remember you will require all the other preprocessor options like /D and /I required to compile the file for this to work.
http://msdn.microsoft.com/en-us/library/b5w2czay(VS.71).aspx