Develop/Error log
Visual studio error C4996 ‘xxxx’ : this function or variable may be unsafe
퓨림노
2020. 7. 15. 19:18
728x90
반응형
Introduction
Visual studio를 사용하면서 아래와 같은 오류를 접하게 됩니다. 아래의 간단한 오류에 대해 알아보고 해결방법에 대해 확인해보도록 하겠습니다.
원인과 해결방법
#Source code
#include <iostream>
#include <stdio.h>
using namespace std;
void main()
{
FILE *p = fopen("test.txt", "W");
// ...
}
#Error message
C4996 ‘xxxx': This function or variable may be unsafe. Consider using xxxxx instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
#원인
Visual studio 초기버전에서는 없었던 오류이지만, 버전업을 진행하면서 MS사에서 C Run time library function 때문에 visual studio에서 오류로 표기하기 시작하였습니다.
#해결방법1
-
영문) Property pages > C++ > preprocessor Definitions 에 아래내용 추가
-
한글) 구성속성 > C/C++ > 전처리기 > 전처리기 정의 에 이래내용 추가
-
;_CRT_SECURE_NO_WARNINGS
#해결방법2
소스코드에서 아래의 내용추가를합니다.
# 조건 (include 위에 작성)
#define _CRT_SECURE_NO_WARNINGINGS
또는,
# 조건 (include 아래 작성)
#pragma warning(disable:4996)
#결과
728x90
반응형