Visual Studio 11 中生成命令和属性的宏
首先由三部分组成的问题:
- 构建时宏在 Visual Studio 11 中是否已完全充实?
- 我如何编辑&在 IDE 中定义它们?
- 如何让宏在调试会话期间仍然具有其含义?
请注意,我指的是 构建时宏,例如 < code>$(ProjectDir),而不是用于记录一系列击键的 IDE 宏 - 它们 把它们拿走了,但是没有他们我也能活下去。我一直通过 Visual Studio 10 中的属性页定义自己的构建时宏。例如,我可能会创建一个宏来定义 Boost 在本地计算机上安装的位置,名为 $(BoostDir)
x64 通过View>Property Manager>Microsoft.Cpp.x64.user构建:
我使用此功能是因为我可能(例如)将 Boost 安装在不同计算机上的不同位置。这些属性是特定于计算机的,不会签入源代码管理。然后,我可以在签入源代码管理的项目设置中使用这些宏,并且只要我为该机器定义了宏,它就应该在我编译该项目的每台机器上工作。
>在 Visual Studio 11 开发人员预览版中运行我的 VS10 项目时,我遇到了一些与这些宏相关的问题。
首先,在 VS11 中似乎没有一个接口来定义这些用户定义的宏。它们在 VS10 中的位置,现在在 VS11 中什么也没有:
看来这些宏确实存在于编译器/IDE 中的某个级别,因为我能够毫无错误地编译我的项目,如果这些宏不存在于某处,我将无法做到这一点。
其次,虽然宏似乎在构建过程中存在,但它们在调试会话期间似乎并不存在。我用来解析 VS10 中某些 DLL 存在的目录的宏现在无法解析 VS11 中的这些目录,并且我收到运行时错误:
该 DLL 所在的目录在 VS10 和 VS11 中定义为:
...但是我的宏在调试会话期间似乎没有任何意义。
如何在 VS11 中获取我在 VS10 中依赖的所有宏相关功能?
Three-part question first:
- Are the build-time macros fully fleshed out in Visual Studio 11?
- How can I edit & define them in the IDE?
- How can I let the macros still have their meaning during the Debugging session?
Note that I'm referring to the build-time macros such as $(ProjectDir)
, not the IDE macros used to record a series of keystrokes -- they took those away, but I can live without them. I have been defining my own build-time macros via the property pages in Visual Studio 10. For example, I might create a macro to define where Boost is installed on my local computer named $(BoostDir)
in x64 builds via View>Property Manager>Microsoft.Cpp.x64.user:
I use this functionality because I might have (for example) Boost installed in different locations on different computers. These properties are machine-specific, and not checked in to source control. I can then use these macros in the project settings which are checked in to source control, and it should work on every machine I compile this project on so long as I have defined the macros for that machine.
In trying to compile & run my VS10 projects in the Visual Studio 11 Developer Preview, I'm running in to a couple of issues with respect to these macros.
First, in VS11 there does not appear to be an interface to define these user-defined macros. Where they were in VS10, there is now just nothing in VS11:
It appears that these macros do exist at some level within the Compiler/IDE, because I am able to compile my project without errors, which I wouldn't be able to do if these macros didn't exist somewhere.
Second, while the macros seem to exist during the build process, they don't appear to exist during the Debugging session. Macros I used to resolve the directories where certain DLLs exist in VS10 now don't resolve those directories in VS11, and I get run-time errors:
The directory where this DLL is located is defined here in VS10 and VS11:
...but my macros don't seem to mean anything during the debug session.
How can I get all the macro-related functionality I depended upon in VS10 back in VS11?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您还没有弄清楚如何执行此操作,则需要使用您自己的属性表。
新建一个属性表,使用Common Properties > 中的部分用户宏。
例如,我在名为 IncludeBoost.props 的属性表中有一个名为 BOOST_VER 的宏,我在其中设置了所有内容。
请注意,也选择了正确的平台(Win32 或 x64)。
顺便说一句,属性管理器支持 Ctrl+单击多项选择。
HTH。
If you haven't already figured out how to do this, you need to use your own property sheets.
Make a new property sheet, and use the section in Common Properties > User Macros.
For example, I have a macro called BOOST_VER in a property sheet called IncludeBoost.props that I set everything in.
Note that the proper platform is picked too (Win32 or x64).
BTW, the Property Manager supports Ctrl+click multiple selection.
HTH.
我的 Microsoft.Cpp.x64.user.props(我认为是您编辑的内容)位于我的 %blah%\AppData\Local\Microsoft\MSBuild\v4.0 中。我的猜测是 VS11 不使用此选项进行构建设置。您真正应该做的是创建自己的属性表以与您的项目。
My Microsoft.Cpp.x64.user.props, which I think is what you edited, sits in my %blah%\AppData\Local\Microsoft\MSBuild\v4.0. My guess is that VS11 doesn't use this one for build settings. What you really should do is creating your own property sheet to use with your projects.