如何使用Windows 8 C++/WinRT组件中的OutputDebugString

Jam*_*add 2 c++ debugging visual-studio windows-8

我正在尝试将一些调试信息写入WinRT组件中的Visual Studio输出窗口.我跑过了函数OutputDebugString,这似乎做了我想要的,但是当我尝试在我的应用程序中使用它时,我得到"错误'OutputDebugString'标识符未找到".我是C++的新手,我错过了"使用命名空间"或包含?

Han*_*ant 5

您需要添加:

 #include <..\um\debugapi.h>
Run Code Online (Sandbox Code Playgroud)

示例电话:

App::App()
{
    InitializeComponent();
    Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
    OutputDebugString(L"App initialized\n");
}
Run Code Online (Sandbox Code Playgroud)

  • 另外我在编译时没有得到这个:错误C1189:#error:"No Target Architecture" (2认同)