468,278 Members | 1,580 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,278 developers. It's quick & easy.

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 17168
Banfa
9,033 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

Post your reply

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

Similar topics

45 posts views Thread by Matt Parkins | last post: by
2 posts views Thread by Jonathan Mcdougall | last post: by
1 post views Thread by zs | last post: by
3 posts views Thread by Hendrik Schober | last post: by
17 posts views Thread by B. Williams | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.