By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 1,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

Error:D8021 Visual Studio 2013

P: 5
Hello Guys,

Expand|Select|Wrap|Line Numbers
  1. invalid numeric argument '_CRT_SECURE_NO_WARNINGS
Expand|Select|Wrap|Line Numbers
  1. error D8021: invalid numeric argument '/wd_CRT_SECURE_NO_WARNINGS'
  2.  
I can't build. I did try close warnings its just work for one.
Oct 21 '15 #1
Share this Question
Share on Google+
5 Replies


P: 15
Where (and how) are you trying to use _CRT_SECURE_NO_WARNINGS?
Oct 21 '15 #2

P: 5
Expand|Select|Wrap|Line Numbers
  1. HANDLE WINAPI hook_CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
  2. {
  3.     HANDLE Result;
  4.  
  5.     // Get custom file path
  6.     wchar_t CustomFile[MAX_PATH] = L"FUUEL\\";
  7.     wcscat(CustomFile, lpFileName);
  8.  
  9.     // See if custom file exists (By setting CreationDisposition to OPEN_EXISTING the API will only open the file if it exists)
  10.     if (detour_CreateFileW->GetOriginalFunction()(CustomFile, dwDesiredAccess, dwShareMode, lpSecurityAttributes, OPEN_EXISTING, dwFlagsAndAttributes, hTemplateFile) != INVALID_HANDLE_VALUE)
  11.     {
  12.         // Our File Exists
  13.         Result = detour_CreateFileW->GetOriginalFunction()(CustomFile, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
  14.     }
  15.     else
  16.     {
  17.         // Use origional File
  18.         Result = detour_CreateFileW->GetOriginalFunction()(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
  19.     }
  20.     return Result;
  21. }
ERROR :

Expand|Select|Wrap|Line Numbers
  1. error C4996: 'wcscat': This function or variable may be unsafe. Consider using wcscat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  2.  
Oct 22 '15 #3

P: 15
I would recommend you use wcscat_s as the warning recommends.

Expand|Select|Wrap|Line Numbers
  1. wcscat_s(CustomFile, MAX_PATH, lpFileName);
Otherwise, you need to define _CRT_SECURE_NO_WARNINGS. You can do this by right clicking on your project and select Properties->C++->Preprocessor and add it to the definitions.
Oct 22 '15 #4

P: 5
I did but its giving an error again

like this :

Expand|Select|Wrap|Line Numbers
  1. error D8021: invalid numeric argument '/wd_CRT_SECURE_NO_WARNINGS'
  2.  
Oct 23 '15 #5

P: 15
How are you defining _CRT_SECURE_NO_WARNINGS? Make sure it is not defined anywhere in your code, then go to Project Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions and add _CRT_SECURE_NO_WARNINGS. Then go to Project Properties -> Configuration Properties -> C/C++ -> Command Line and look at in the All Options box and see what is there. Among the options you should see /D "_CRT_SECURE_NO_WARNINGS". You should not see /wd_CRT_SECURE_NO_WARNINGS. The correct /wd option to disable this warning would be /wd4996. If everything looks OK on the project properties, right click on the source file itself and check the command line options the same way.
Oct 25 '15 #6

Post your reply

Sign in to post your reply or Sign up for a free account.