HolidayXue / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

sample2.cc generates warning on windows vs2005 #45

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. compile sample2.cc with Visual Studio 2005

Output from compiler is:

cc(52) : 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.'

I don't want to have to #define _CRT_SECURE_NO_DEPRECATE

Original issue reported on code.google.com by keith....@gmail.com on 6 Oct 2008 at 6:22

Attachments:

GoogleCodeExporter commented 9 years ago
my suggested fix is one line:  change strcpy, that MSVS is complaining about, 
to memcpy.

old:
strcpy(clone, c_string);

new:
memcpy(clone, c_string, len + 1);

patch file is attached.

Original comment by keith....@gmail.com on 6 Oct 2008 at 6:43

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by shiq...@gmail.com on 8 Oct 2008 at 9:10

GoogleCodeExporter commented 9 years ago
Keith, 
I am putting the change in, together with another sample fix (that one for VS 
7.1).
They may take a week or two to filter to svn, though -- we are busy with the 
other
things right now.

Original comment by vladlosev on 9 Oct 2008 at 1:02

GoogleCodeExporter commented 9 years ago

Original comment by shiq...@gmail.com on 12 Oct 2008 at 3:21

GoogleCodeExporter commented 9 years ago
Fixed in revision 135.

Original comment by vladlosev on 22 Nov 2008 at 6:08