Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
string literal cast to 'LPWSTR'
Remarks
The compiler detected an unsafe cast. The cast did succeed, but you should use a conversion routine.
This warning is off by default. See Compiler Warnings That Are Off by Default for more information.
Example
The following example generates C4906:
// C4906.cpp
// compile with: /W1
#pragma warning(default : 4906)
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{
LPWSTR x = (LPWSTR)"1234"; // C4906
// try the following lines instead
// char y[128];
// size_t numberOfCharConverted = 0;
// errcode err = 0;
// err = wcstombs_s(&numberOfCharConverted , &y[0], 128,
// L"12345", 4);
// if (err != 0)
// {
// printf_s("wcstombs_s failed!");
// return -1;
// }
// printf_s("%s\n", y);
return 0;
}