This function or variable may be unsafe. To disable obsolescence, use _CRT_SECURE_NO_WARNINGS

I am working on a C ++ dll, no matter how I run into some problems, I get the following problem: some places

Severity Code Description Project File Line Suppression State Error C4996 'sprintf': This function or variable may be unsafe. Use sprintf_s instead. To disable obsolescence, use _CRT_SECURE_NO_WARNINGS. See the online help for more information.

I tried using this: #define _CRT_SECURE_NO_WARNINGS but the problem remains, this is the code:

    sprintf(szDebugString, "%s: 0x%x (%s%s%i)", ptrName, (DWORD)funcPtr, interfaceName, interfaceVersion.c_str(), i);
+4
source share
2 answers

You must specify _CRT_SECURE_NO_WARNINGSbefore #include <Windows.h>.

:

sprintf_s(szDebugString, sizeof(szDebugString), "%s: 0x%x (%s%s%i)",
    ptrName, (DWORD)funcPtr, interfaceName, interfaceVersion.c_str(), i);
+4

stdafx.h.

.

#pragma once
#define _CRT_SECURE_NO_WARNINGS

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>
+1

All Articles