From: William S F. <ws...@fu...> - 2013-01-31 20:15:19
|
Sounds like a problem with precompiled headers. What if you clean your project completely of all temporary visual studio files and start again with just the %begin containing the #include "stdafx.h" and no pragma in stdafx.h. In order for precompiled headers to work properly, all your .cpp files require the #include "stdafx.h", but in all honesty I gave up using precompiled headers in Visual Studio years ago as they never really worked properly and seemed to cause various strange effects. William On 31/01/13 19:58, Olivier Voyer wrote: > William: I just checked and no, I don't define this macro in my project. > I'm using SWIG with C++ to generate Python code. I've seen this piece of > code in the wrapped C++ code, but it seems the _CRT_SECURE_NO_DEPRECATE > isn't working. > > #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && > !defined(_CRT_SECURE_NO_DEPRECATE) > # define _CRT_SECURE_NO_DEPRECATE > #endif > > David: I don't know why, but when I put the #pragma command in the SWIG > .i file, it doens't work, the warning is still displayed. I have to put > the #pragma command in stdafx.h and include it in the .i file, and it works. > > %begin > %{ > #include "stdafx.h" > %} > > On Thu, Jan 31, 2013 at 2:44 PM, David Piepgrass > <dpi...@me... <mailto:dpi...@me...>> wrote: > > > > I'm using SWIG in Visual Studio 2010 with C++ and when I > compile the > > > .cpp generated by SWIG I receive a bunch of warnings concerning > > > deprecated functions (such as strcpy and strncpy). Is there a > way to > > > correct that in SWIG, other than to ignore those warnings in my > project? > > > Normally I try to avoid the #pragma command as much as > possible, but I > > > know #pragma warning(disable : 4996) would do the trick. > > > > > > 2>SWIG\swig_application_wrap.cpp(692): 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. > > > 2> C:\Program Files (x86)\Microsoft Visual Studio > > > 10.0\VC\include\string.h(105) : see declaration of 'strcpy' > > > 2>SWIG\swig_application_wrap.cpp(717): 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> C:\Program Files (x86)\Microsoft Visual Studio > > > 10.0\VC\include\string.h(188) : see declaration of 'strncpy' > > > > > They may indeed by unsafe, but they are not deprecated despite > what the > > compiler is saying. > > > > You should not see these warnings too as by default SWIG does define > > _CRT_SECURE_NO_WARNINGS unless > > SWIG_NO_CRT_SECURE_NO_DEPRECATE is defined. This approach could be > > tweaked given the new C11 macro __STDC_WANT_LIB_EXT1__. Did you > > define the SWIG_NO_CRT_SECURE_NO_DEPRECATE macro? If not, then > > something has gone wrong. Which language module are you using? > > In my project I have to use these traditional C functions, and > defining _CRT_SECURE_NO_WARNINGS and _CRT_NON_CONFORMING_SWPRINTFS > doesn't work reliably even if I put it in front of everything else > in StdAfx.h. So thanks for the tip about #pragma warning, Olivier! > You can of course put it at the beginning of the generated SWIG > wrapper with > > %insert("begin") > %{ > #pragma warning(disable : 4996) > %} > > > > > -- > *Olivier Voyer* > oliviervoyer.com <http://oliviervoyer.com/> > /L'aube d'un jour nouveau/ > / > / |