Error:D8021 Visual Studio 2013

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mumya0236
    New Member
    • Oct 2015
    • 5

    Error:D8021 Visual Studio 2013

    Hello Guys,

    Code:
    invalid numeric argument '_CRT_SECURE_NO_WARNINGS
    Code:
    error D8021: invalid numeric argument '/wd_CRT_SECURE_NO_WARNINGS'
    I can't build. I did try close warnings its just work for one.
  • hpmachining
    New Member
    • Oct 2015
    • 15

    #2
    Where (and how) are you trying to use _CRT_SECURE_NO_ WARNINGS?

    Comment

    • mumya0236
      New Member
      • Oct 2015
      • 5

      #3
      Code:
      HANDLE WINAPI hook_CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
      {
      	HANDLE Result;
      
      	// Get custom file path
      	wchar_t CustomFile[MAX_PATH] = L"FUUEL\\";
      	wcscat(CustomFile, lpFileName);
      
      	// See if custom file exists (By setting CreationDisposition to OPEN_EXISTING the API will only open the file if it exists)
      	if (detour_CreateFileW->GetOriginalFunction()(CustomFile, dwDesiredAccess, dwShareMode, lpSecurityAttributes, OPEN_EXISTING, dwFlagsAndAttributes, hTemplateFile) != INVALID_HANDLE_VALUE)
      	{
      		// Our File Exists
      		Result = detour_CreateFileW->GetOriginalFunction()(CustomFile, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
      	}
      	else
      	{
      		// Use origional File
      		Result = detour_CreateFileW->GetOriginalFunction()(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
      	}
      	return Result;
      }
      ERROR :

      Code:
      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.

      Comment

      • hpmachining
        New Member
        • Oct 2015
        • 15

        #4
        I would recommend you use wcscat_s as the warning recommends.

        Code:
        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.
        Last edited by hpmachining; Oct 22 '15, 04:14 PM. Reason: I removed the part about not tested. I have since tested.

        Comment

        • mumya0236
          New Member
          • Oct 2015
          • 5

          #5
          I did but its giving an error again

          like this :

          Code:
          error D8021: invalid numeric argument '/wd_CRT_SECURE_NO_WARNINGS'

          Comment

          • hpmachining
            New Member
            • Oct 2015
            • 15

            #6
            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_N O_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.

            Comment

            Working...