I am using Microsoft Visual Studio, and it issues a C4996 warning, for example:
warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead.
warning C4996: 'chsize': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _chsize.
What the hell is this and how to deal with it?
Answer 1, authority 100%
Microsoft has deprecated a number of functions / This is because these functions do not check for buffer overflows. For example,
char str [5]; ... strcpy (str, "Hello World!");
in this case, strcpy will write outside the allocated buffer (Hello World! is 13 char’s (with a terminating 0), not 5, which can lead to changes in the values of other dynamic variables, overwriting information on the stack – it is difficult errors found during program execution … To eliminate this shortcoming, “safe” functions with the _s (fscanf_s) suffix were developed … To disable the issuance of these messages, declare a macro
# define _CRT_SECURE_NO_WARNINGS
or (depending on the version of the header files), possibly
# define _CRT_SECURE_NO_DEPRECATE
before including the standard library header files.
To disable the “POSIX” message, you can use
#define _CRT_NONSTDC_NO_DEPRECATE
can also try
# pragma warning (disable: 4996)