简体   繁体   English

错误C2440:“正在初始化”:无法从“ const wchar_t [9]”转换为“ LPCSTR”

[英]error C2440: 'initializing' : cannot convert from 'const wchar_t [9]' to 'LPCSTR'

When I add the following to my code. 当我将以下内容添加到我的代码中时。

// Define the input layout
D3D10_INPUT_ELEMENT_DESC layout[] =
{
    { L"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },  
};
UINT numElements = sizeof(layout)/sizeof(layout[0]);

I get the following error 我收到以下错误

1>c:\users\numerical25\desktop\intro todirectx\msdntutorials\tutorial0\tutorial\tutorial\main.cpp(43) : error C2440: 'initializing' : cannot convert from 'const wchar_t [9]' to 'LPCSTR'

The error points straight to that line of code. 错误直接指向该行代码。 if i remove the code, everything compiles correctly. 如果我删除了代码,一切都会正确编译。

The problem is that first element of D3D10_INPUT_ELEMENT_DESC needs a const char * , not a const wchar_t * . 问题在于D3D10_INPUT_ELEMENT_DESC的第一个元素需要一个const char * ,而不是const wchar_t * Just remove the L before the string. 只需删除字符串前面的L

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误C2440&#39;=&#39;:无法从&#39;cli :: array转换 <Type> ^&#39;至&#39;wchar_t&#39; - Error C2440 '=' : cannot convert from 'cli::array<Type> ^' to 'wchar_t' 使用VC ++ 2013-Windows 10编译Qt5.9时,出现错误C2440:“默认参数”:无法从“ const wchar_t [1]”转换为“ BSTR” - While compiling Qt5.9 with VC++2013 - Windows 10, getting error C2440: 'default argument': cannot convert from 'const wchar_t [1]' to 'BSTR' 错误 C2440:“正在初始化”:无法从“const mynamespace::mytype*”转换为“const T*” - error C2440: 'initializing' : cannot convert from 'const mynamespace::mytype*' to 'const T*' mex 编译错误 C2440:“正在初始化”:无法从“const mwSize *”转换为“const int32_t *” - mex compilation error C2440: 'initializing': cannot convert from 'const mwSize *' to 'const int32_t *' 错误C2440:“正在初始化”:在Visual Studio 2008中无法从“ const jchar *”转换为“ LPCWSTR” - error C2440: 'initializing' : cannot convert from 'const jchar *' to 'LPCWSTR' in Visual Studio 2008 错误C2440:&#39;初始化&#39;:无法从&#39;const int&#39;转换为&#39;int *&#39; - error C2440: 'initializing' : cannot convert from 'const int' to 'int *' 错误 C2440:“正在初始化”:无法从“const char *”转换为“TCHAR *” - error C2440: 'initializing': cannot convert from 'const char *' to 'TCHAR *' 错误C2440:“正在初始化”:无法从“ const temp1”转换为“ temp2” - error C2440: 'initializing' : cannot convert from 'const temp1' to 'temp2' 错误C2440:“正在初始化”:无法从“ LPVOID”转换为“ UINT” - error C2440: 'initializing' : cannot convert from 'LPVOID' to 'UINT 错误 C2440:“正在初始化”:无法从“CTable”转换为“CTable” - Error C2440: 'initializing': cannot convert from 'CTable' to 'CTable'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM