_CRT_SECURE_NO_WARNINGS Seems To Be Inconsistent.

  • Thread starter Thread starter a_unique_name
  • Start date Start date
A

a_unique_name

Guest
Hello Folks:

Developing on Windows 10 Pro, Visual Studio 2017 Community.

My application that calls strncpy() and other functions cause warnings in Visual Studio. I can live with those warnings.

I've reinstalled Visual Studio this week and I'm seeing both warnings and errors generated from the same call to strncpy in the header I built to interface with the Firebird database.

3><path>\firebird_utilities.h(151): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

2><path>\firebird_utilities.h(151): error C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.



This might hold a clue to the resolution of this problem.

A warning is generated by every project that has an include for this header file, except one.

That error is generated by the build of the Firebird utility's project. The property page for firebird_utilities, all configurations and all platforms, has Treat Warnings As Errors set to No(/WX-).

This is the source that generates many warnings and 1 error.

#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS

inline void test_function()
{
const char *text_source = "hello";
char text_destination[10];

strncpy(text_destination, text_source, 10); <------- Line 151
}
#endif


As you can see, _CRT_SECURE_NO_WARNINGS is defined before the function call.

Suggestions?

Thanks
Larry

Continue reading...
 
Back
Top