473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

"warning C4996: 'strncpy' was declared deprecated"

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?
Nov 17 '05 #1
7 16801
Yes, you should use strncpy_s. See "Security Enhancements in the CRT" on
MSDN.

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
"Olaf Baeyens" <ol**********@skyscan.be> wrote in message
news:42***********************@news.skynet.be...
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?

Nov 17 '05 #2
> Yes, you should use strncpy_s. See "Security Enhancements in the CRT" on
MSDN.

Thanks :-)
Nov 17 '05 #3
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/5...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).

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #4
Olaf Baeyens wrote:
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
Nov 17 '05 #5
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/si...6355/n1093.pdf

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #6
Jochen Kalmbach [MVP] wrote:
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/si...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
Nov 17 '05 #7
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
discussion).


The standard can be found here:
http://www.opengroup.org/platform/si...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.


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).

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ReignMan | last post by:
I'm running JDK 1.4.0_01, Xalan2.5.1 and Tomcat 4.1.27. XSL transformations work, yet when running in debug mode (Eclipse IDE), I get the following: 990S2html.xsl:3:80: Element type...
1
by: Derek | last post by:
I am writing a web application for job seekers, and am adding a section that allows administrators to upload jobs to the system via xml. I have used an xml schema to validate the xml they upload....
1
by: Bimal | last post by:
Hi, I upgraded my gcc from 2.95 to 3.3. When I compile some projects I get error messages saying... /usr/local/include/c++/3.3/ctime:68: error: `tm' not declared...
1
by: dtdev | last post by:
hi, i have a: char record = new char; In this i am loading a fixedlength record from a file. What i would like to do, is to copy segments from this array into either smaller strings or ...
5
by: Torben Laursen | last post by:
I am writing a COM in C# using visual studio 2005 and VSTO. Inside the code I use some support classes that are generic but they are not used in the inferface of the COM. However I still get a...
4
by: PH.D.Condidater.Li.Ning | last post by:
Hi, all, I am using an uninitialised variable that generating a 'Run-Time Check Failure #3' when the debug version is running. The code is complex and changing it would be risky, so how do I...
4
by: lostlander | last post by:
In ARMCC, and Microsoft C, when i use a function which is never defined or delared, it gives out a warning, not a compiling error? why? (This leads to a bug to my program since I seldom pay much...
2
by: Thelma Lubkin | last post by:
I use my own matrix and vector classes. I wrote them before such things were generally available and I've stuck with them ever since. I've just added an Octonion class derived from the vectors...
2
by: DelphiCoder | last post by:
I have the following function declared: void RegisterMyClass(HINSTANCE hinst, WNDPROC wproc, char* clsName) My window procedure is defined as follows: LRESULT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.