Ram*_*lol 1 c++ winapi visual-c++
为什么我得到'CA2W':找不到标识符
for(DWORD i = 0; i < numMaterials; i++) // for each material...
{
material[i] = tempMaterials[i].MatD3D; // get the material info
material[i].Ambient = material[i].Diffuse; // make ambient the same as diffuse
USES_CONVERSION; // allows certain string conversions
// if there is a texture to load, load it
D3DXCreateTextureFromFile(d3ddev,
CA2W(tempMaterials[i].pTextureFilename),
&texture[i]);
texture[i] = NULL; // if there is no texture, set the texture to NULL
}
Run Code Online (Sandbox Code Playgroud)
CA2W找不到,因为Express版本不包括整个ATL/MFC库.因此,我原来的答案与OP无关.
故事的寓意:确保在提出这些问题时确切地提到你所处的环境.
CA2W您可以使用MultiByteToWideChar()- 而不是使用- 此函数实际上用于CA2W转换字符串,因此您将获得基本相同的结果.
这是MultiByteToWideChar()另一个Stack溢出问题的答案中的用法示例.它是从转换std::string到LPCWSTR,但它基本上是相同的过程.
#include <atlbase.h>
#include <atlconv.h>
int main()
{
// Explicitly qualified the CA2W identifier
ATL::CA2W("Hello World!"); // Test to see if this compiles
}
Run Code Online (Sandbox Code Playgroud)
我想,为什么这个代码片段之前没有工作的原因是因为你#define倒是_ATL_NO_AUTOMATIC_NAMESPACE在什么地方#include <atlbase.h>.
| 归档时间: |
|
| 查看次数: |
12454 次 |
| 最近记录: |