Sign in to follow this  
stealthgate

Visual Studio 2005 deprecation warnings?

Recommended Posts

I just recently got VS 2005 and attempted to port an old VC++ 6 to the new IDE. My problem comes from deprecated function calls.... Primary when I call an stdio.h function such as fopen, it says it is deprecated, and my program doesn't function. It says to use the safe version of the function or disable deprecation. Any suggestions? How would I go about disabling deprecation? Thanks for any help! - stealthgate

Share this post


Link to post
Share on other sites
Quote:
Original post by Dave
Hey bud,

You could always use the now standard equivelent of stdio.h, cstdio. This should do the trick.

Hope that helps,

Dave


If I remember correctly, then no, not in 2005. The "problem" with 2005 is that it has deprecated most functions from the C library like fopen, strcpy, sprintf etc. They have replaced them with new ones, but these are only available on MSVC 2005. To disable the warnings you have to define some constant, I think it is _CRT_SECURE_NO_DEPRECATE before including the headers.

Like this:

#define _CRT_SECURE_NO_DEPRECATE
#include <cstdio>

Share this post


Link to post
Share on other sites
Quote:
Original post by CTar
Quote:
Original post by Dave
Hey bud,

You could always use the now standard equivelent of stdio.h, cstdio. This should do the trick.

Hope that helps,

Dave


If I remember correctly, then no, not in 2005. The "problem" with 2005 is that it has deprecated most functions from the C library like fopen, strcpy, sprintf etc. They have replaced them with new ones, but these are only available on MSVC 2005. To disable the warnings you have to define some constant, I think it is _CRT_SECURE_NO_DEPRECATE before including the headers.

Like this:

#define _CRT_SECURE_NO_DEPRECATE
#include <cstdio>


Ah fair enough, was just taking a semieducated guess :).

Dave

Share this post


Link to post
Share on other sites
Quote:
Original post by stealthgate
After implementing cstdio, are the functions the same as in stdio? Are there names the same?

Dudes, thanks for the replies!


I believe so. I don't really use C stuff any more.

Dave

Share this post


Link to post
Share on other sites
Quote:
Original post by Dave
Quote:
Original post by stealthgate
After implementing cstdio, are the functions the same as in stdio? Are there names the same?

Dudes, thanks for the replies!


I believe so. I don't really use C stuff any more.

Dave


The names should be in the std namespace, according to the C++ standard.
Quote:

The facilities of the Standard C Library are provided in 18 additional headers, as shown in Table 12:

Table 12 — C++ Headers for C Library Facilities

<cassert> <ciso646> <csetjmp> <cstdio> <ctime>
<cctype> <climits> <csignal> <cstdlib> <cwchar>
<cerrno> <clocale> <cstdarg> <cstring> <cwctype>
<cfloat> <cmath> <cstddef>

Except as noted in clauses 18 through 27, the contents of each header cname shall be the same as that of the corresponding header name.h, as specified in ISO/IEC 9899:1990 Programming Languages C (Clause 7), or ISO/IEC:1990 programming Languages—C AMENDMENT 1: C Integrity, (Clause 7), as appropriate, as if by inclusion. In the C + + Standard Library, however, the declarations and definitions (except for names which are defined as macros in C) are within namespace scope (3.3.5) of the namespace std.

Names which are defined as macros in C shall be defined as macros in the C + + Standard Library, even if C grants license for implementation as functions. [Note: the names defined as macros in C include the following:
assert, errno, offsetof, setjmp, va_arg, va_end, and va_start. —end note]


In MSVC 2005 you can access them in the global namespace or in the std namespace. So no need to change the names if you will just be using MSVC 2005

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this