numerical25
numerical25

Reputation: 10790

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.

Upvotes: 1

Views: 9231

Answers (1)

leiz
leiz

Reputation: 4042

The problem is that first element of D3D10_INPUT_ELEMENT_DESC needs a const char *, not a const wchar_t *. Just remove the L before the string.

Upvotes: 5

Related Questions