Correct use of _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES?

  • Thread starter Thread starter Mark Findlay
  • Start date Start date
M

Mark Findlay

I am using the #define for _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES in my
Windows MFC App, (Visual Studio 2005) and yet continue to receive compiler
warnings about various CRT functions.

It was my impression that setting the #define of
_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES to 1 would automatically adjust the
old CRT function calls I had in my code to accommodate the new size-checking
format. However, when I step through the code in debug, it appears to step
into the older unsafe CRT function.

My stdafx.h file has the following defined at the very bottom:

//---------------------------------------
// The following #defines ensure that safe CRT functions are automatically
used.
#undef _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
#undef _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT 1
//----------------------------------------

And when I display the value at runtime, it shows the correct value:

m_util.OutputDebugString(_T("_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=%d"),_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES);

So why, when I compile, do I still get the compiler warnings, and why, when
I step through a CRT function, is it still stepping into the old function?

Thanks!
Mark
 
I am using the #define for _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES in my
Windows MFC App, (Visual Studio 2005) and yet continue to receive compiler
warnings about various CRT functions.

It was my impression that setting the #define of
_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES to 1 would automatically adjust the
old CRT function calls I had in my code to accommodate the new size-checking
format.

Mark,

It'll do it for those situations where the compiler knows the size to
use. Where it can't find the size (where the parameter is just a
pointer rather than a known array size) it still uses the old version.

Dave
 
Back
Top