I would be grateful for some help.
We have an Open Source project that compiles without warnings using
wxWidgets 2.8.12. However, on moving to 3.0.1 (or 3.0.2), one source
member (and only one source member) produces 51 warning message C4996 as
below. No other source member produces any errors or warnings on moving
from 2.8.12 to 3.0.1.
We have set the pre-processor variables:
"_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1" and
"_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1", which should use the
"Secure Template Overloads" to automatically change to use the secure
versions, as per
http://msdn.microsoft.com/en-us/library/ms175759%28v=vs.120%29.aspx, as I
think happens with wxWidgets 2.8.12.
The C4996 warning messages suggest to use _CRT_SECURE_NO_WARNINGS to
suppress these messages but we want to use the secure versions and need the
warnings to ensure that we do.
This one source member is very simple - a cutdown copy of the example for
copying and retrieving data from the clipboard
(
http://docs.wxwidgets.org/trunk/classwx_clipboard.html).
The issue is caused just by including the STL header file <string> (or any
header
file that includes it) before "<wx/clipbrd.h>" & "<wx/dataobj.h>" and, as we
wish
to use std::wstring variables as member variables and as parameters in any
future functions, then it must be included in the Header file (Test.h below)
and
we normally place that at the top of the source file (Text.cpp below).
It appears to be the order of "#include <string>" vs "#include
<wx/clipbrd.h>" & "#include <wx/dataobj.h>".
Thank you.
Our source member:
#include "Test.h"
#include <wx/clipbrd.h>
#include <wx/dataobj.h>
#ifdef __WXMSW__
#include <wx/msw/msvcrt.h>
#endif /* __WXMSW__ */
bool TestClipboard::ClearData()
{
// TBD
return false;
}
Our header "Test.h":
#ifndef _Test_H_
#define _Test_H_
#include <string>
namespace TestClipboard {
// Future member variables/functions using std::wstring
bool ClearData();
}
#endif /* _Test_H_ */
Warning messages:
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(209): 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.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(112) : see declaration of 'strcpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(211): warning C4996: 'wcscpy':
This function or variable may be unsafe. Consider using wcscpy_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(294) : see declaration of 'wcscpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(213): 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.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(112) : see declaration of 'strcpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(215): 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.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(112) : see declaration of 'strcpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(217): 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.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(112) : see declaration of 'strcpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(219): warning C4996: 'wcscpy':
This function or variable may be unsafe. Consider using wcscpy_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(294) : see declaration of 'wcscpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(221): warning C4996: 'wcscpy':
This function or variable may be unsafe. Consider using wcscpy_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(294) : see declaration of 'wcscpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(223): warning C4996: 'wcscpy':
This function or variable may be unsafe. Consider using wcscpy_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(294) : see declaration of 'wcscpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(225): 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.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(112) : see declaration of 'strcpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(227): warning C4996: 'wcscpy':
This function or variable may be unsafe. Consider using wcscpy_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(294) : see declaration of 'wcscpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(230): 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.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(195) : see declaration of 'strncpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(232): warning C4996: 'wcsncpy':
This function or variable may be unsafe. Consider using wcsncpy_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(323) : see declaration of 'wcsncpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(234): 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.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(195) : see declaration of 'strncpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(236): 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.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(195) : see declaration of 'strncpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(238): 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.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(195) : see declaration of 'strncpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(240): warning C4996: 'wcsncpy':
This function or variable may be unsafe. Consider using wcsncpy_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(323) : see declaration of 'wcsncpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(242): warning C4996: 'wcsncpy':
This function or variable may be unsafe. Consider using wcsncpy_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(323) : see declaration of 'wcsncpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(244): warning C4996: 'wcsncpy':
This function or variable may be unsafe. Consider using wcsncpy_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(323) : see declaration of 'wcsncpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(246): 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.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(195) : see declaration of 'strncpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(248): warning C4996: 'wcsncpy':
This function or variable may be unsafe. Consider using wcsncpy_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(323) : see declaration of 'wcsncpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(260): 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.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(195) : see declaration of 'strncpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(273): warning C4996: 'wcsncpy':
This function or variable may be unsafe. Consider using wcsncpy_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(323) : see declaration of 'wcsncpy'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(281): warning C4996: 'strcat':
This function or variable may be unsafe. Consider using strcat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(118) : see declaration of 'strcat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(283): warning C4996: 'wcscat':
This function or variable may be unsafe. Consider using wcscat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(284) : see declaration of 'wcscat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(285): warning C4996: 'strcat':
This function or variable may be unsafe. Consider using strcat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(118) : see declaration of 'strcat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(287): warning C4996: 'strcat':
This function or variable may be unsafe. Consider using strcat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(118) : see declaration of 'strcat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(289): warning C4996: 'strcat':
This function or variable may be unsafe. Consider using strcat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(118) : see declaration of 'strcat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(291): warning C4996: 'wcscat':
This function or variable may be unsafe. Consider using wcscat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(284) : see declaration of 'wcscat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(293): warning C4996: 'wcscat':
This function or variable may be unsafe. Consider using wcscat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(284) : see declaration of 'wcscat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(295): warning C4996: 'wcscat':
This function or variable may be unsafe. Consider using wcscat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(284) : see declaration of 'wcscat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(297): warning C4996: 'strcat':
This function or variable may be unsafe. Consider using strcat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(118) : see declaration of 'strcat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(299): warning C4996: 'wcscat':
This function or variable may be unsafe. Consider using wcscat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(284) : see declaration of 'wcscat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(302): warning C4996: 'strncat':
This function or variable may be unsafe. Consider using strncat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(186) : see declaration of 'strncat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(304): warning C4996: 'wcsncat':
This function or variable may be unsafe. Consider using wcsncat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(316) : see declaration of 'wcsncat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(306): warning C4996: 'strncat':
This function or variable may be unsafe. Consider using strncat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(186) : see declaration of 'strncat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(308): warning C4996: 'strncat':
This function or variable may be unsafe. Consider using strncat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(186) : see declaration of 'strncat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(310): warning C4996: 'strncat':
This function or variable may be unsafe. Consider using strncat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(186) : see declaration of 'strncat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(312): warning C4996: 'wcsncat':
This function or variable may be unsafe. Consider using wcsncat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(316) : see declaration of 'wcsncat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(314): warning C4996: 'wcsncat':
This function or variable may be unsafe. Consider using wcsncat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(316) : see declaration of 'wcsncat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(316): warning C4996: 'wcsncat':
This function or variable may be unsafe. Consider using wcsncat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(316) : see declaration of 'wcsncat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(318): warning C4996: 'strncat':
This function or variable may be unsafe. Consider using strncat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(186) : see declaration of 'strncat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(320): warning C4996: 'wcsncat':
This function or variable may be unsafe. Consider using wcsncat_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\string.h(316) : see declaration of 'wcsncat'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(754): warning C4996: '_wfopen':
This function or variable may be unsafe. Consider using _wfopen_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\stdio.h(590) : see declaration of '_wfopen'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(756): warning C4996:
'_wfreopen': This function or variable may be unsafe. Consider using
_wfreopen_s instead. To disable deprecation, use
_CRT_SECURE_NO_WARNINGS. See online help for details.
C:\Program Files
(x86)\Microsoft Visual Studio 12.0\VC\include\stdio.h(592) : see
declaration of '_wfreopen'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(923): warning C4996: 'getenv':
This function or variable may be unsafe. Consider using _dupenv_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\stdlib.h(462) : see declaration of 'getenv'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(924): warning C4996:
'_wgetenv': This function or variable may be unsafe. Consider using
_wdupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
See online help for details.
C:\Program Files (x86)\Microsoft Visual
Studio 12.0\VC\include\stdlib.h(711) : see declaration of '_wgetenv'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(925): warning C4996: 'getenv':
This function or variable may be unsafe. Consider using _dupenv_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\stdlib.h(462) : see declaration of 'getenv'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(926): warning C4996: 'getenv':
This function or variable may be unsafe. Consider using _dupenv_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\stdlib.h(462) : see declaration of 'getenv'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(927): warning C4996: 'getenv':
This function or variable may be unsafe. Consider using _dupenv_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\stdlib.h(462) : see declaration of 'getenv'
..\VC\wxWidgets\3.0.1\include\wx/wxcrt.h(928): warning C4996:
'_wgetenv': This function or variable may be unsafe. Consider using
_wdupenv_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
See online help for details.
C:\Program Files (x86)\Microsoft Visual
Studio 12.0\VC\include\stdlib.h(711) : see declaration of '_wgetenv'
..\VC\wxWidgets\3.0.1\include\wx/filefn.h(515): warning C4996: '_wopen':
This function or variable may be unsafe. Consider using _wsopen_s
instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\include\wchar.h(368) : see declaration of '_wopen'