469,268 Members | 1,010 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,268 developers. It's quick & easy.

Correct use of _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES?

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_OVERL OAD_STANDARD_NAMES=%d"),_CRT_SECURE_CPP_OVERLOAD_S TANDARD_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
Mar 4 '07 #1
2 4969
>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
Mar 4 '07 #2
Hi, Mark,
Sorry for delaying this response, since I am consulting the product team on
this issue. The process may need a long time and I appreciate your patience.

You are right. Per my test, such code:
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT 1
...
char szBuf[10];
strcpy(szBuf, "test");

could not work fine as described in the article:
Secure Template Overloads
http://msdn2.microsoft.com/en-us/lib...8VS.80%29.aspx

The old version function will also be invoked.

Could you please mail me a response so that I can timely update you when I
get a response from the product team?
My email address is changliw_at_microsoft_dot_com.

If you have any other questions or concerns, please feel free to let me
know.
Have a good day!

Charles Wang
Microsoft Online Community Support
================================================== ===
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
================================================== ====
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
================================================== ====
This posting is provided "AS IS" with no warranties, and confers no rights.
================================================== ====

Mar 7 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by David Opstad | last post: by
reply views Thread by Sarah Tegtmeier | last post: by
1 post views Thread by Richard Golebiowski | last post: by
6 posts views Thread by Rob Thorpe | last post: by
5 posts views Thread by blackg | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.