Skip to content

Latest commit

 

History

History
48 lines (39 loc) · 1.14 KB

compiler-warning-level-1-c4905.md

File metadata and controls

48 lines (39 loc) · 1.14 KB
descriptiontitlems.datef1_keywordshelpviewer_keywordsms.assetid
Learn more about: Compiler Warning (level 1) C4905
Compiler Warning (level 1) C4905
11/04/2016
C4905
C4905
40240bf4-b14e-4c22-aeb2-52f2851532f6

Compiler Warning (level 1) C4905

wide string literal cast to 'LPSTR'

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 sample generates C4905.

// C4905.cpp// compile with: /W1 #pragma warning(default : 4905) #include<windows.h> #include<stdlib.h> #include<stdio.h>intmain() { LPSTR y = (LPSTR)L"1234"; // C4905// try the following lines instead// wchar_t y[128];// size_t sizeOfConverted;// errcode err = 0;//// err = mbstowcs_s(&sizeOfConverted, &y[0], 128, "12345", 4);// if (err != 0)// {// printf_s("mbstowcs_s failed!");// exit (-1);// }// wprintf(L"%s\n", y);return0; }
close