473,836 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

strncpy_s and gcc ?

I have been doing some (re)search on the VS-warning
warning C4996: 'strncpy' was declared deprecated

It seems to be a MS-way to force strncpy to become deprecated, but it
is not ISO-deprecated.

However MS wants this to be replaced with strncpy_s
1) Is it c++,TR1 or just MS standard (TR proposal) ?

2) gcc 4.1.1 does not seem to have strncpy_s - is that correct
(Or do I miss an include or something)

Oct 17 '06
11 18589

Jim Langston wrote:
"tmartsum" <tm******@gmail .comwrote in message

ISO allows any warning, as long as legal C++ code still works.

OK - so MS is allowed to give any warning - I am however not happy with
warnings that suggest me to change my code into something that is not
(ISO) c++...

That's Microsoft for you. And it should be _strncpy_s since it's an
extension. Microsoft did that from some calls from VC6 to VC .net 2003,
but on this one I think they thought it would be in the new standard or
something.
Not necessarily. Whether strncpy_s is defined or not could be made
dependent on the definition of an implementation-reserved identifier.
Since no conforming program would have already defined this identifier,
there is no chance that the these extensions would break a conforming
program. Instead, a C or C++ program has to first define
__STDC_WANT_LIB _EXT1__ before it can call any of the routines in the TR
"bounds-checked" extension to the standard C library.

Greg

Oct 18 '06 #11

tmartsum wrote:
Mi************* @tomtom.com skrev:
tmartsum wrote:
I have been doing some (re)search on the VS-warning
warning C4996: 'strncpy' was declared deprecated
<snip discussion of strncpy vs strncpy_s>
ISO allows any warning, as long as legal C++ code still works.

OK - so MS is allowed to give any warning - I am however not happy with
warnings that suggest me to change my code into something that is not
(ISO) c++...
Depending on your level of unhappiness, you have several options. For
example, you could do one or more of the following:

Contact Microsoft and give them your feedback as a customer.
Vote with your feet and change to a different compiler vendor.
Look in Microsoft's documentation for the way to switch off that
warning now you understand why it's there and why you don't want it.

The last one has worked for me.

Gavin Deane

Oct 18 '06 #12

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

Similar topics

45
11738
by: Matt Parkins | last post by:
Hi, (I realise this probably isn't precisely the right group for this - could someone direct me to the appropriate group to post this question? - thanks !) I'm using Visual C++ 2005 Express Edition Beta (free download from MS - hooray!), and everything works fine, except I get warnings back on the use of some functions, strlen() for example, saying that the function has been deprecated - although they do still work (which is I guess...
68
3743
by: Roman Ziak | last post by:
Hello, I just downloaded MS Visual Studio 2005 Express Beta. When I tried to compile existing valid project, I get a lot of warnings like 'sprintf' has been deprecated, 'strcpy' has been deprecated etc. I opened STDIO.H and figured that one has to define a macro _CRT_SECURE_NO_DEPRECATE to stop these warnings. I started to search internet and found few links, and the following proposal
7
16827
by: Olaf Baeyens | last post by:
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?
62
4149
by: Juuso Hukkanen | last post by:
I am looking for a wish list of things which should be removed from the C (C99) - due to feature's bad security track record <OT>or Multithreading unsafety. I need this list for a project intending to build another (easiest & most powerful) programming language, which has a two page definition document stating: "... includes C programming language (C99), except its famous "avoid-using-this-functions". </OT> If you would not want to...
7
2028
by: jacob navia | last post by:
Microsoft proposed recently (In the Technical Report 24173 presented to the Standards Comitee) a change in the C library in the sense of more security. Basically, missing size information is passed to the new primitives like strcat_s(), gets_s(), and many others. The good thing in this proposal is that the specifications of the new library are much more precise than in the existing library, an improvement that made me start...
7
2101
by: AlanJSmith | last post by:
I am converting some C++ projects from 6 to vs2005 in one of the headers i have the code that follows this passage in which I get an error saying int default cant be assumed so i added DBString<nSizeDBString<nSize>:: to the copy assignment same size oporator and this seems to work, if i try the same thing with copy assignment different sizes i get error C3856: 'DBString<nSize>::=': class is not a class template and adding any type between...
11
2390
by: OmarOthman | last post by:
How does the MS Visual C++ 6.0 compiler deal with the following?! int main() { ... } I mean that there's no "return 0;". There's no int returned at all. How does this compile?! I'm a C# expert, and this never compiles on C#. Please explain your answer in terms of what the compiler assumes and what it does actually... Thanks in advance.
70
3651
by: junky_fellow | last post by:
Guys, If main() calls some function func() and that function returns the error (errno), then does it make sense to return that value (errno) from main. (in case main can't proceed further) ? eg. int main(void) {
0
1806
by: Dilip | last post by:
I have cross-posted this question to 3 newsgroups since I am not sure exactly where it belongs (and some NG's have very less activity). Apologies in advance for this. I have set the followup to the dotnet.framework.interop NG but feel free to chage it as appopriate. I have a question regarding converting a Managed System.String^ to unmanaged const char*. I inherited a code that does it like this: String^ s = "00000";
0
9665
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10834
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10541
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10584
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10248
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9367
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7782
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
4006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3108
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.