Discussion:
_CRT_SECURE_NO_DEPRECATE doesn't appear to work as described
(too old to reply)
matman13
2006-08-10 18:55:01 UTC
Permalink
I have an MFC application that I uplifted to Visual Studio 2005 a couple of
months ago. As expected, there were warnings and errors that had to be dealt
with. One of the warnings, C4996, was addressed by putting the
_CRT_SECURE_NO_DEPRECATE macro in the project settings for each subproject of
the solution. That worked great.

Fast forward two months. Someone else has formally uplifted our MFC
application to Visual Studio 2005 (mine was just an exercise to see what was
involved). One of the subproject is encountering warnings again dealing with
C run-time functions being deprecated, such as strcpy. In his case, though,
he gets a C4996 warning AND a C4995 warning for each occurrence. Putting the
_CRT_SECURE_NO_DEPRECATE macro in the project settings only suppresses the
C4996 warning. The C4995 warning still exists.

Does anyone have an idea as to why this is? I cannot reproduce his problem
with my original uplifted project. But the .vcproj files for this particular
subproject are identical between his solution and mine. For the life of me,
I cannot figure out why he is seeing the C4495 warning and I NEVER did.

Any guidance is greatly appreciated. I would prefer to avoid using the
#pragma directive to turn off the warning, but I'm not sure that that's not
the only recourse at this point. Any gurus out there that can point me in
the right direction?
David Lowndes
2006-08-11 10:37:53 UTC
Permalink
Post by matman13
In his case, though,
he gets a C4996 warning AND a C4995 warning for each occurrence. Putting the
_CRT_SECURE_NO_DEPRECATE macro in the project settings only suppresses the
C4996 warning. The C4995 warning still exists.
Had you perhaps also used the other definitions - such as

_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1
_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1
Post by matman13
But the .vcproj files for this particular
subproject are identical between his solution and mine.
Clearly something must be different.

If you supply a few lines of code and the exact error message, someone
might be able to offer a more informed insight.

Dave
matman13
2006-08-11 13:27:02 UTC
Permalink
Post by David Lowndes
Had you perhaps also used the other definitions - such as
_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1
_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1
No. But I've tried using these in the project that is generating the C4995
warnings to no avail.
Post by David Lowndes
Clearly something must be different.
I think the same thing. I'm just unclear as to what.
Post by David Lowndes
If you supply a few lines of code and the exact error message, someone
might be able to offer a more informed insight.
There's really no code to show. Here is the text from both warnings.

test.cpp(122) : warning C4995: 'strcpy': name was marked as #pragma deprecated
test.cpp(122) : warning C4996: 'strcpy' was declared deprecated
c:\program files\microsoft visual studio 8\vc\include\string.h(73) : see
declaration of 'strcpy'
Message: 'This function or variable may be unsafe. Consider using
strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See
online help for details.'

Notice that both warnings reference the same occurrence of strcpy. If I add
_CRT_SECURE_NO_DEPRECATE to the project settings, the C4996 warning is
suppressed as expected. However, the C4995 warning still shows up.

The issue is that I <b>never</b> see the C4995 warning in my test uplift
project. To this day, that warning has never and still does not occur. But
in the "formal" uplifted project, this warning does occur.

Can anyone explain what might be causing the C4995 warning to occur in one
project but not in another? C4995 and C4996 are both level 1 warnings. Are
there perhaps IDE settings or settings in the top-level solution file that
would cause this difference? Could it be due to a difference in the way the
project was uplifted? The guy who formally uplifted the project did it from
a machine that only had Visual Studio 2005 installed, i.e., the machine did
not have a previous version of VS installed. Could that be the problem? If
it is, wouldn't it still manifest itself in some difference in the project
settings? Or could the C4995 warning be suppressed on my machine because of
some kind of weird interaction between VS 2003 and VS 2005 (I've got both
installed).
David Lowndes
2006-08-11 16:09:19 UTC
Permalink
Post by matman13
Notice that both warnings reference the same occurrence of strcpy. If I add
_CRT_SECURE_NO_DEPRECATE to the project settings, the C4996 warning is
suppressed as expected. However, the C4995 warning still shows up.
Is there anything different with the definitions of strcpy in the 2
projects? i.e. are the include paths picking up the same header file?

I've seen strange behaviour converting some projects - individual
files get their own preprocessor project settings and don't inherit
the project ones - but from what you said it doesn't sound like that's
happening.

Dave
Leo V.
2006-11-03 04:14:39 UTC
Permalink
How exactly in this project are you defining _CRT_SECURE_NO_DEPRECATE? If
it's in your stdafx.h file, perhaps test.cpp is not using the stdafx.h file
(and thus would not get the #define).

On the same token, if you are defining it through project settings. Maybe
test.cpp has been overridden. Right-click on test.cpp file in the solution
explorer and select properties. Look at the preprocessor settings specific
to that CPP file. If there are any, you may want to remove them (to go back
to using the default project settings).

LeoV.
Post by matman13
Post by David Lowndes
Had you perhaps also used the other definitions - such as
_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1
_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1
No. But I've tried using these in the project that is generating the C4995
warnings to no avail.
Post by David Lowndes
Clearly something must be different.
I think the same thing. I'm just unclear as to what.
Post by David Lowndes
If you supply a few lines of code and the exact error message, someone
might be able to offer a more informed insight.
There's really no code to show. Here is the text from both warnings.
test.cpp(122) : warning C4995: 'strcpy': name was marked as #pragma deprecated
test.cpp(122) : warning C4996: 'strcpy' was declared deprecated
c:\program files\microsoft visual studio 8\vc\include\string.h(73) : see
declaration of 'strcpy'
Message: 'This function or variable may be unsafe. Consider using
strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See
online help for details.'
Notice that both warnings reference the same occurrence of strcpy. If I add
_CRT_SECURE_NO_DEPRECATE to the project settings, the C4996 warning is
suppressed as expected. However, the C4995 warning still shows up.
The issue is that I <b>never</b> see the C4995 warning in my test uplift
project. To this day, that warning has never and still does not occur.
But
in the "formal" uplifted project, this warning does occur.
Can anyone explain what might be causing the C4995 warning to occur in one
project but not in another? C4995 and C4996 are both level 1 warnings.
Are
there perhaps IDE settings or settings in the top-level solution file that
would cause this difference? Could it be due to a difference in the way the
project was uplifted? The guy who formally uplifted the project did it from
a machine that only had Visual Studio 2005 installed, i.e., the machine did
not have a previous version of VS installed. Could that be the problem?
If
it is, wouldn't it still manifest itself in some difference in the project
settings? Or could the C4995 warning be suppressed on my machine because of
some kind of weird interaction between VS 2003 and VS 2005 (I've got both
installed).
Loading...