在C ++ Microsoft Visual Studio 2010中调试多个环境变量

在C ++ Microsoft Visual Studio 2010中调试多个环境变量

问题描述:

设置环境变量时,Visual Studio 2010 Professional C ++调试器遇到一个非常简单的问题.

I got a very simple problem with the Visual Studio 2010 Professional C++ debugger when setting environment variables.

描述于
http://msdn.microsoft.com/zh-cn/library/kcw4dzyf. aspx
段落环境(本地Windows调试器)".

Described in
http://msdn.microsoft.com/en-en/library/kcw4dzyf.aspx
Paragraph "Environment (Local Windows Debugger)".

我创建了一个标准的Win32控制台项目.我在项目属性→ Debugger :

I created a standard Win32 console project. I am setting the environment in project properties → Debugger:

TEST=asdf
OTHER=qwer

并在_tmain(...)中打印环境变量:

And printing the environment variables in the _tmain(...):

cout << "Hello " << getenv("TEST") << endl;

我希望这样的结果:

"Hello asdf"

但是我总是得到:

"Hello asdf OTHER=qwer"

如何解决此问题?!

这似乎是DEU版本的错误.

It seems to be a DEU version bug.

我刚刚提交了一个错误报告: https://connect.microsoft.com/VisualStudio/feedback/details/727324/msvs10-c-deu-debugger-environment-variables-missing-linefeed#details

I just filed a bug report: https://connect.microsoft.com/VisualStudio/feedback/details/727324/msvs10-c-deu-debugger-environment-variables-missing-linefeed#details

到目前为止最好的解决方案:

Best solution so far:

考虑您的示例:

TEST=asdf
OTHER=qwer

编辑在<Project>中添加的.vcxproj:

  <Project .... >
  ...

  <PropertyGroup Label="UserMacros">
  <TEST>asdf</TEST>
  <OTHER>qwer</OTHER>
  </PropertyGroup>

  ...
  </Project>

您也可以根据需要将其添加到*.vcxproj.user*.props文件中.

You can also add this on a *.vcxproj.user or a *.props file as you prefer.