Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2005

Tip: Looking for answers? Try searching our database.

"warning C4996: 'strncpy' was declared deprecated"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Olaf Baeyens - 28 Jul 2005 12:55 GMT
I am testing VC++ 2005 and I get this warning:
"warning C4996: 'strncpy' was declared deprecated"

Does that mean that they might be phased out in VC++ 2006 or higher?
Or does an alternative function exist as replacement?
Nishant Sivakumar - 28 Jul 2005 13:11 GMT
Yes, you should use strncpy_s. See "Security Enhancements in the CRT" on
MSDN.

Signature

Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com

>I am testing VC++ 2005 and I get this warning:
> "warning C4996: 'strncpy' was declared deprecated"
>
> Does that mean that they might be phased out in VC++ 2006 or higher?
> Or does an alternative function exist as replacement?
Olaf Baeyens - 28 Jul 2005 13:14 GMT
> Yes, you should use strncpy_s. See "Security Enhancements in the CRT" on
> MSDN.

Thanks :-)
Jochen Kalmbach [MVP] - 28 Jul 2005 13:16 GMT
Hi Olaf!
> I am testing VC++ 2005 and I get this warning:
> "warning C4996: 'strncpy' was declared deprecated"
> Does that mean that they might be phased out in VC++ 2006 or higher?

Yes.

> Or does an alternative function exist as replacement?

See: strncpy_s
http://msdn2.microsoft.com/library/5dae5d43(en-us,vs.80).aspx

Almost for every deprecated CRT function there is a "xxx_s" function
available (only for strdup, there is only a _strdup).

Signature

Greetings
  Jochen

   My blog about Win32 and .NET
   http://blog.kalmbachnet.de/

Tom Widmer [VC++ MVP] - 28 Jul 2005 13:54 GMT
> I am testing VC++ 2005 and I get this warning:
> "warning C4996: 'strncpy' was declared deprecated"
>
> Does that mean that they might be phased out in VC++ 2006 or higher?

Not likely, since strncpy is an ISO C and C++ function, and is more
efficient than strncpy_s. The deprecation warning is not intended to
indicate that the standard functions will be removed, but rather to
indicate potentially unsafe code. In fact, the _s functions are of
dubious use in any case, since they don't make it significantly easier
to write correct code in many cases (though they do make it easier to
improve legacy code). There is a #define to get rid of the warnings, I
forget what it is though.

> Or does an alternative function exist as replacement?

strncpy_s, but that is non-standard and non-portable for the time being
(but there is a controversial C standard technical report under discussion).

Tom
Jochen Kalmbach [MVP] - 28 Jul 2005 14:26 GMT
Hi Tom!

> There is a #define to get rid of the warnings, I
> forget what it is though.

The following defines can be used to get rid of the warnings:
- _CRT_SECURE_NO_DEPRECATE
- _CRT_­NONSTDC_NO_DEPRECATE
- _USE_32BI­T_TIME_T

>> Or does an alternative function exist as replacement?
>
> strncpy_s, but that is non-standard and non-portable for the time being
> (but there is a controversial C standard technical report under
> discussion).

The standard can be found here:
http://www.opengroup.org/platform/single_unix_specification/uploads/40/6355/n1093.pdf

Signature

Greetings
  Jochen

   My blog about Win32 and .NET
   http://blog.kalmbachnet.de/

Tom Widmer [VC++ MVP] - 28 Jul 2005 14:52 GMT
>> strncpy_s, but that is non-standard and non-portable for the time
>> being (but there is a controversial C standard technical report under
>> discussion).
>
> The standard can be found here:
> http://www.opengroup.org/platform/single_unix_specification/uploads/40/6355/n1093.pdf 

I think it's worth making it clear that it isn't a standard, but rather
a draft technical report, and one that may never become a real technical
report, and will almost certainly never become part of the full C or C++
standards.

Tom
Jochen Kalmbach [MVP] - 29 Jul 2005 07:20 GMT
Hi Tom!

>>> strncpy_s, but that is non-standard and non-portable for the time
>>> being (but there is a controversial C standard technical report under
[quoted text clipped - 7 lines]
> report, and will almost certainly never become part of the full C or C++
> standards.

There are a lot of misleading discussions in this area.
And I will not add my comment here... (in any case, it will be
interpreted the wrong way).

Signature

Greetings
  Jochen

   My blog about Win32 and .NET
   http://blog.kalmbachnet.de/


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.