【问题标题】:define debug using Unicode Character Set使用 Unicode 字符集定义调试
【发布时间】:2013-05-12 10:27:11
【问题描述】:

我正在关注一本名为“DirectX 9.0c 3D 游戏编程简介:一种着色器方法”的书,其中所有示例都使用 多字节字符集,我不想使用它,我不希望我的项目出现在多个再见章节中。我的问题是书上有调试功能,这里是代码。

//debug
#if defined(DEBUG) | defined(_DEBUG)
    #ifndef HR
    #define HR(x)                                      \
    {                                                  \
        HRESULT hr = x;                                \
        if(FAILED(hr))                                 \
        {                                              \
            DXTrace(__FILE__, __LINE__, hr, #x, TRUE); \
        }                                              \
    }
    #endif

#else
    #ifndef HR
    #define HR(x) x;
    #endif
#endif 

然后在我的 .cpp 文件中,我使用书中的这段代码来创建设备。

HR(md3dObject->CreateDevice(
        D3DADAPTER_DEFAULT, // primary adapter
        mDevType,           // device type
        mhMainWnd,          // window associated with device
        devBehaviorFlags,   // vertex processing
        &md3dPP,            // present parameters
        &gd3dDevice));      // return created device

那么错误是。 错误 C2664:“DXTraceW”:无法将参数 4 从“const char [107]”转换为“const WCHAR *”

希望有人可以帮助我。谢谢。

【问题讨论】:

  • 这本书教给你的不仅仅是一种坏习惯。 CreateDevice() 失败必须结束程序。摆脱这本书。

标签: windows direct3d


【解决方案1】:

尝试将参数从#x更改为L#x,或者使用微软的宏_T(#x)

【讨论】:

    猜你喜欢
    • 2015-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多