OutputDebugString 在 Visual Studio 2010 中不打印信息
我一直在尝试让 OutputDebugString
工作但无济于事。我的代码如下:
int main(int argc, char* argv[])
{
OutputDebugStringA("asd");
getchar();
return 0;
}
当我在没有调试的情况下运行应用程序时,DebugView 显示 asd
但当我调试应用程序 (F5) 时,它不会在输出或中间窗口中打印我的字符串。
我已经尝试使用 asd
来输出调试字符串,但没有任何改变。可能是什么问题?
I've been trying to get OutputDebugString
to work with no avail. My code follows:
int main(int argc, char* argv[])
{
OutputDebugStringA("asd");
getchar();
return 0;
}
When I run the application without debugging, DebugView shows asd
but when I debug my application (F5), it doesn't print my string in Output or Intermediate window.
I've tried OutputDebugString with asd
but nothing changed. What can be the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该用“\n”终止字符串,但这应该只是一个装饰性的东西。我现在已经尝试过你的代码,我可以在 VS 2010 的输出窗口中看到 asd 字符串,没有任何问题。
注意:在“输出”窗格的上下文菜单中(可使用鼠标右键单击访问),您可以选择应在窗格中显示哪些信息。确保您已启用“程序输出”。还要确保您正在观看正确的窗口(输出或立即),具体取决于您在工具/选项/调试/常规中设置的“将所有输出窗口文本重定向到立即窗口”。
You should terminate the string with "\n", but this should be only a cosmetic thing. I have tried your code right now and I can see the asd string in the Output window of VS 2010 without any issues.
Note: in the context menu of the Output pane (accessible using right mouse click) you can select which information should be displayed in the pane. Make sure you have enabled "Program output". Also make sure you are watching the correct window (Output or Immediate) depending on your setting "Redirect all Output window text to the Immediate window" in Tools/Options/Debugging/General.
我们在 x64 混合模式调试方面也遇到了类似的问题,因此如果您使用的是 64 位,请检查主启动项目的“调试”属性页。调试器类型应设置为“混合”而不是“自动”才能查看本机以及托管调试输出。
请参阅此处了解更多信息。
We had a similar issue with x64 mixed mode debugging, so if you are using 64 bit check the Debugging property page for the main startup project. The Debugger Type should be set to 'Mixed' rather than 'Auto' to see native as well as managed debug output.
See here for more info.