C:不推荐使用从字符串常量转换为’LPSTR {aka char *}'[-Wwrite-strings] – 警告.怎么避免?
在编译C代码时,我收到此警告:
deprecated conversion from string constant to ‘LPSTR {aka char*}’
[-Wwrite-strings]
&pi)) // Pointer to PROCESS_INFORMATION structure.
^
代码是:
STARTUPINFO si;
memset(&si, 0, sizeof (STARTUPINFO));
si.cb = sizeof (STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = FALSE;
PROCESS_INFORMATION pi;
memset(&pi, 0, sizeof (PROCESS_INFORMATION));
if (!CreateProcess("C:\\Program Files\\Java\\jre7\\bin\\javaw.exe",
" -jar install.jar", // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
0, // Set handle inheritance to FALSE.
CREATE_NO_WINDOW, // ON VISTA/WIN7, THIS CREATES NO WINDOW
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi)) // Pointer to PROCESS_INFORMATION structure. //Warning comes from this line - variable &pi
{
printf("CreateProcess failed\n");
return 0;
}
是否可以采取措施避免这种情况(我的意思是不使用 – 抑制警告)?