I'm including these three files in my C++ program:

#include <stdio.h>
#include <cstdlib>
#include <iostream.h>

The C++ compiler I am using (Dev-C++ 4.9.9.2) Allows me to run this program. but I still receive an error message saying:

#warning This file includes at least one deprecated or antiquated header. \
Please consider using one of the 32 headers found in section 17.4.1.2 of the \
C++ standard. Examples include substituting the <X> header for the <X.h> \
header for C++ includes, or <iostream> instead of the deprecated header \
<iostream.h>. To disable this warning use -Wno-deprecated.

Why is this happening and how can I stop it? Thanks in advance.

Recommended Answers

All 13 Replies

use cstdio instead of stdio.h and iostream instead of iostream.h

i also had the same pblm and when i used cstdio instead of <stdio.h>,still the compiler was showing error.

What compiler are you using?

iostream.h is obsolete. use <iostream> instead (notice there is no .h extension).

You can replace all three headers with
#include <iostream>

Mine is showing these three errors

1 C:\Dev-Cpp\include\c++\3.4.2\backward\iostream.h:31, from C:\Users\Home\Documents\ATM.cpp In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31, from C:\Users\Home\Documents\ATM.cpp
1 C:\Users\Home\Documents\ATM.cpp from C:\Users\Home\Documents\ATM.cpp
32:2 C:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.

For future reference, errors and warnings are not synonymous. Errors must be fixed because they halt compilation. Warnings can be ignored, though in some cases they suggest problems that are likely to occur at runtime.

Since your compiler clearly supports the modern headers, it's recommended that you use them.

I ALWAYS treat warnings in my own code as errors because most of the time they are errors. We need to know which header files cplusplus is using before we can suggest a solution to fix them.

I am also facing same problem eventhough i used the headers <ios> and <iostream> in my program
but, i'm getting these errors like:

E:\Edu\C_execution\sum.cpp:7: error: expected `:' before "int"

E:\Edu\C_execution\sum.cpp: In member function int sum::add()': E:\Edu\C_execution\sum.cpp:10: error:cout' undeclared (first use this function)
E:\Edu\C_execution\sum.cpp:10: error: (Each undeclared identifier is reported only once for each function it appears in.)

Now plz reply me what should i do to fix it???

First off, I would say that this is different enough that you would have been better off creating a new thread, rather than posting in one several months old. Just for future reference.

While I cannot say for certain without seeing the code, from the error message given it sounds like the issue is namespace scoping. You see, the majority of objects and classes in the standard library are in the std namespace, and have to be scoped for it in order for them to be visible, even if you have the headers which hold them #included already . To do this, you have three options:

  • You can explicitly scope each reference to the object by prepending them with the std:: scope marker; e.g., std::cout, std::endl, std::string, etc. This gives you the best control over the namespace scope, and is the preferred approach, but can be tedious to use.
  • You can add the entire std namespace to the local scope, by using the directive using namespace std; at the top of the source file, right below the #include directives. This is the easiest solution, and the most common, but it loses most of the advantages of having separate namespaces. Most professional programmers avoid this for all but the most trivial programs.
  • You can add the individual clases or objects to the local scope, by using the using X::Y form of the directive, e.g., using std::cout;. This lets you use that specific objects without explicit scoping, without polluting your local namespace with the whole std namespace's identifiers. This option is good for when you have a lot of references to a specific class or object, but don't want he whole namespace in scope. It tends to be under-utilized, as most programmers aen't familiar with this form of the directive.

Depending on how often you use std::cout, I would either explicitly scope it each time, or, if you are really using it frequently and aren't inclined to add the scope to each and every case, add using std::cout; to the top of the file. I would not recommend using the using namespace std; form, as that's too broad in its effects and can have unintended consequences.

As Schol-R-LEA said, I doubt that your problem resides in using <ios> or <iostream> in your includes.

Since Schol-R-LEA listed the options, I might as well complete the thought with the remark that using-statements like using namespace std; or using std::cout; can also appear within function bodies, and, in fact, that is the preferred option of "professional" programmers. So, the order of preference (from preferred to to-be-avoided) is this:

  1. Prefer using only individual using-clauses (like using std::cout;) in the function bodies; or else,
  2. Use only individual using-clauses in the global or namespace scope within your cpp files; or else,
  3. Use a namespace using-clause in the cpp files; but,
  4. Never put a using-clause in a header file (1).

(1): Except for the specific purpose of transfering a class or function from one namespace to another (this is a common trick in library-code).

Also, another small correction:

You see, the majority of objects and classes in the standard library are in the std namespace

Not the majority... ALL standard classes, objects and functions are in the std namespace (and std::tr1, and std::tr2 to come), even those from C standard libraries (like cmath or cstdlib). Some compilers put C functions in the global namespace, but that is not a standard feature (the standard mandates that they be in the std namespace, but allows the compiler-vendors to put them in global namespace also, but some don't, like MSVC). Worse yet, sometimes the global-namespace version of C libraries are not C++ friendly (e.g., no overloading of abs() for type double), and those who are unaware of this issue could get bad surprises.

commented: Excellent points +7

Don't panic guys
just comment all the header files which are ending with .h like #include<limits.h> etc...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.