Regarding the generated warning C4996: 'std::_Traits_helper::copy_s' was declared deprecated

I have a query regarding the warning C4996.I'm attaching a set of code, To which i'm trying to compile in visual studio 2005 Beta 2. But It sucessfully compiled but generating  warning.I'm not able to find the solution to resolve the warning.

Generated warning is also below.

Could you tell whats i'm doing wrong.

*****************************************************

C2440typecast.cpp

*****************************************************
typedef
TCHAR TChar;

struct case_insensitive_char_traits : public std::char_traits<TChar>

{

   static bool __CLRCALL_OR_CDECL eq( const _Elem& First, const _Elem& Second )

   {

      return ( _totupper( First ) == _totupper( Second ) );

   } // eq

   static bool __CLRCALL_OR_CDECL lt( const _Elem& First, const _Elem& Second )

   {

      return ( _totupper( First ) < _totupper( Second ) );

   } // lt

   static int __CLRCALL_OR_CDECL compare( const _Elem *pFirst, const _Elem *pSecond,

      size_t nElements )

   {

         return _tcsnicmp(pFirst, pSecond, nElements);

   } // compare

  static const _Elem * __CLRCALL_OR_CDECL find( const _Elem *pString, size_t nElements,

      const _Elem& Element )

   {

      const _Elem *pRet = 0;

      size_t iElement;

      if ( !pString ) goto AllDone;

      for ( iElement = 0; iElement < nElements; iElement ++ )

      {

         if ( eq( pString[ iElement ], Element ) )

         {

            pRet = &pString[ iElement ];

            goto AllDone;

         }

      } // for

      AllDone:

      return pRet;

   } // find

};

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{

std::basic_string<TChar, case_insensitive_char_traits > TStr;

return 1;

}

**********************************************************************


*******************************************************************************************

------ Build started: Project: C2440typecast, Configuration: Debug Win32 ------

Compiling...

C2440typecast.cpp

c:\program files\microsoft visual studio 8\vc\include\iosfwd(582) : warning C4996: 'std::_Traits_helper::copy_s' was declared deprecated

c:\program files\microsoft visual studio 8\vc\include\iosfwd(598) : see declaration of 'std::_Traits_helper::copy_s'

c:\program files\microsoft visual studio 8\vc\include\xstring(1999) : see reference to function template instantiation 'std::char_traits<wchar_t>::char_type *std::_Traits_helper::copy_s<_Traits>(std::char_traits<wchar_t>::char_type *,size_t,const std::char_traits<wchar_t>::char_type *,size_t)' being compiled

with

[

_Traits=case_insensitive_char_traits

]

c:\program files\microsoft visual studio 8\vc\include\xstring(1992) : while compiling class template member function 'void std::basic_string<_Elem,_Traits>::_Tidy(bool,__w64 unsigned int)'

with

[

_Elem=TChar,

_Traits=case_insensitive_char_traits

]

c:\documents and settings\akumar.scicom\desktop\c2440typecast\c2440typecast\c2440typecast.cpp(65) : see reference to class template instantiation 'std::basic_string<_Elem,_Traits>' being compiled

with

[

_Elem=TChar,

_Traits=case_insensitive_char_traits

]

c:\program files\microsoft visual studio 8\vc\include\iosfwd(601) : warning C4996: 'std::char_traits<wchar_t>::copy' was declared deprecated

c:\program files\microsoft visual studio 8\vc\include\iosfwd(331) : see declaration of 'std::char_traits<wchar_t>::copy'

c:\program files\microsoft visual studio 8\vc\include\iosfwd(582) : see reference to function template instantiation 'std::char_traits<wchar_t>::char_type *std::_Traits_helper::copy_s<_Traits>(std::char_traits<wchar_t>::char_type *,size_t,const std::char_traits<wchar_t>::char_type *,size_t,std::_Unsecure_char_traits_tag)' being compiled

with

[

_Traits=case_insensitive_char_traits

]

c:\program files\microsoft visual studio 8\vc\include\xstring(1999) : see reference to function template instantiation 'std::char_traits<wchar_t>::char_type *std::_Traits_helper::copy_s<_Traits>(std::char_traits<wchar_t>::char_type *,size_t,const std::char_traits<wchar_t>::char_type *,size_t)' being compiled

with

[

_Traits=case_insensitive_char_traits

]

Linking...

Embedding manifest...

Build log was saved at "file://c:\Documents and Settings\akumar.SCICOM\Desktop\C2440typecast\C2440typecast\Debug\BuildLog.htm"

C2440typecast - 0 error(s), 2 warning(s)

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

 *******************************************************************************************



Answer this question

Regarding the generated warning C4996: 'std::_Traits_helper::copy_s' was declared deprecated

  • anodize

    That seems correct for now till the libraries folks finish their investigations. I will keep you updated.

    Thanks,
      Ayman Shoukry
      VC++ Team

  • JimmyV

    Hi Ayman,

    Thanks a lot for the same. Now i'm able to compile my code with switch /D_SCL_SECURE_NO_DEPRECATE.

    One thing more you means nothing wrong with my code. This warning comes from the VC Libraries right.

    Thanks in advance.

    Ashish Kumar
    Systems Executive
    Scicom Infotech Private Limited.
    A-67, Sector - 57,
    NOIDA - 201301,
    Uttar Pradesh, India
    Tel.   : +91-120-2589992 to 7 (Six lines) Ext. 178
    Fax    : +91-120-2589998
    Mobile : +91-9891448096
    www.scicmp.com

  • LitePipe

    Is this still the last word on this problem I am getting these warnings 2 years later.


  • gordonk

    I'm getting this error in the production version of VC2005. Was this issue ever resolved The error occurs in in the MS header file iosfwd under circumstances basically the same as previously given in this thread. It seems that ideally the MS header files should not call deprecated functions. Will there be a new version available
  • Kopelli

    I am suspecting something seems not correct in the VC headers. I have asked the Libraries folks to take a look.

    Meanwhile, you can just define _SCL_SECURE_NO_DEPRECATE either at the start of your code (before the include) or via the compiler switch /D_SCL_SECURE_NO_DEPRECATE.

    Thanks,
      Ayman Shoukry
      VC++ Team

  • Regarding the generated warning C4996: 'std::_Traits_helper::copy_s' was declared deprecated