실행환경

 Desktop

 조립식

 CPU

 Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz 3.40GHz

 Memory

 8.00 GB

 OS

 Windows 7 Professional K 64bit

 Java

 1.8.0_05

 MySQL

 Ver 14.14 Distrib 5.6.19, for Win64

 Web Server

 Apache Tomcat 7.0.51


문제점

컴파일시 아래와 같은 에러 중 어느 한가지라도 발생했을 경우.(확실치는 않다.)

Warning    2    warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    336    1    Programa 3205
Warning    3    warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    363    1    Programa 3205
Warning    4    warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    369    1    Programa 3205
Warning    5    warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    371    1    Programa 3205
Warning    6    warning C4996: 'strtok': This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    374    1    Programa 3205
Warning    7    warning C4996: 'strtok': This function or variable may be unsafe. Consider using strtok_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    375    1    Programa 3205
Warning    9    warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    718    1    Programa 3205
Warning    10    warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    727    1    Programa 3205
Warning    11    warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    729    1    Programa 3205
Warning    12    warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    754    1    Programa 3205
Warning    13    warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    766    1    Programa 3205
Warning    14    warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    768    1    Programa 3205
Warning    15    warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    792    1    Programa 3205
Warning    16    warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    806    1    Programa 3205
Warning    17    warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    808    1    Programa 3205
Warning    18    warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    830    1    Programa 3205
Warning    19    warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    842    1    Programa 3205
Warning    20    warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    844    1    Programa 3205
Warning    21    warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    866    1    Programa 3205
Warning    22    warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    911    1    Programa 3205
Warning    23    warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    f:\fernando luiz\teste-3205\ps3000.c    939    1    Programa 3205

해결방안


Project properties > Configuration Properties > C/C++ > Preprocessor > Preprocessor Definitions > _CRT_SECURE_NO_WARNINGS
프로젝트 오른쪽 클릭 > 속성 > 구성 속성 > C/C++ > 전처리기 > 전처리기 정의 > _CRT_SECURE_NO_WARNINGS 추가.

보안상의 문제로 다른 함수를 사용하라는 것인데 설정 추가로 해결할 수 있다.

 실행환경

 Desktop

 조립식

 CPU

 Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz 3.40GHz

 Memory

 8.00 GB

 OS

 Windows 7 Professional K 64bit

 Java

 1.8.0_05

 MySQL

 Ver 14.14 Distrib 5.6.19, for Win64

 Web Server

 Apache Tomcat 7.0.51


문제점

유닉스에서 사용하던 함수 open(), close(), write(), read()를 window Visual Studio 에서 사용하려하는데 에러 발생.

해결방안

_open()을 사용한다. 다른 함수 모두 앞에 '_'를 붙혀 사용한다. 아래 코드는 MS Developer Network C 라이브러리에서 참고하였다.

#include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <io.h> #include <stdio.h> int main( void ) { int fh1, fh2; fh1 = _open( "CRT_OPEN.C", _O_RDONLY ); // C4996 // Note: _open is deprecated; consider using _sopen_s instead if( fh1 == -1 ) perror( "Open failed on input file" ); else { printf( "Open succeeded on input file\n" ); _close( fh1 ); } fh2 = _open( "CRT_OPEN.OUT", _O_WRONLY | _O_CREAT, _S_IREAD | _S_IWRITE ); // C4996 if( fh2 == -1 ) perror( "Open failed on output file" ); else { printf( "Open succeeded on output file\n" ); _close( fh2 ); } }


참고 사이트 링크


+ Recent posts