472,811 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

warning C4996: 'fopen' was declared deprecated

I do not know how to handle this message:

c:\users\admin\documents\visual studio 2005\projects\vec\vec\fileclass.cpp(40) : warning C4996: 'fopen' was declared deprecated

c:\program files\microsoft visual studio 8\vc\include\stdio.h(234) : see declaration of 'fopen'

Message: 'This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'
Aug 30 '07 #1
2 17797
9,065 Expert Mod 8TB
At it's most basic level it is a warning so you could just ignore it.

Or you can define _CRT_SECURE_NO_DEPRECATE (and from some sources _CRT_NONSTDC_NO_DEPRECATE as well) the best way to do this is by altering the project settings to include the symbols on the compiler command line.

Finally you could change you code to use the new (non-depricated) functions. However before you do that you have to be sure that this code is not portable and will never need to be portable, this is it will always only be targeted at the MS platform.

That is because these functions are only depricated by MS not by the C or C++ standards. While everyone agrees that the C runtime library has many insecure functions that could do with fixing their has been no consensus yet (as far as I am aware) on what the replacement functions should be. MS has just gone ahead and created their own (as have other people).

Anyway if you decide to change the code the clue is in the warning message, use fopen_s (this _s addition to the function name is common in the MS CRT for the newer secure functions, for instance strcpy is replaced by strcpy_s), the parameters are different so you will need to look up the function in your help (but pressing F1 isn't hard) and recode to the new prototype.
Aug 30 '07 #2
Ok, I have used the new fopen_s function and this solved the problem. Thanks.
Sep 3 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

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...
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...
by: Jonathan Mcdougall | last post by:
Visual studio 2005 reports main.cpp(8) : warning C4996: 'std::basic_string<_Elem,_Traits,_Ax>::copy' was declared deprecated with this program: # include <string> int main()
by: Martin Jørgensen | last post by:
Hi, Consider: ------------ char stringinput ..bla. bla. bla. do {
by: zs | last post by:
Hi! I get warning message shown below in VS.NET 2k3. Is this deprecated by microsoft or by standard? I need hash_set to store and search small strings (<20 chars long). I'll have less then 300...
by: Hendrik Schober | last post by:
So we finally switched a big project to VC8. Good. However, now I can't see any compiler messages anymore, because they are burried under gazillions of messages that some C std functions are...
by: B. Williams | last post by:
I am receiving two warnings in my code and can't figure out why. Will someone look at this and tell me what I have done wrong? #include <iostream> using std::cout; #include <string> ...
by: pochipp | last post by:
Hi.. All I got a problem in writing this program becoz I successfullly compiled the file but I cannot run the program since there will be an error when I run it. So I checked again... And there...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.