include problem

S

skumar

I am a newbie with C++ and unable to understand this warning/error
message :

localhost > g++ -Wall j++.cpp
In file included from /usr/include/c++/3.2.2/backward/iostream.h:31,
from j++.cpp:2:
/usr/include/c++/3.2.2/backward/backward_warning.h:32:2: warning:
#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 <sstream> instead of
the deprecated header <strstream.h>. To disable this warning use
-Wno-deprecated.

The offending line is :
#include <iostream.h>

The compiler is GNU C/C++ version : 3.2.2.3
Host OS is : Mandrake Linux 9.1

All help welcome....
 
R

Ron Natalie

skumar said:
#include <iostream.h>
This header is not part of standard C++. It is for G++ an obsolete header. The standard
header is called <iostream>. This defines the stream stuff into the std namespace as well.
This means that in addtition to changing the header you must place explicitly qualify the
stuff from that header (std::cout for example) or bring then into the current context with
using directives (using std::cout or even using namespace std). Do not place using directives
in headers that you expect others to use. It's not nice to pollute their namespace. Stick
to the explicit qualification in headers.
 
?

=?iso-8859-1?Q?Juli=E1n?= Albo

skumar escribió:
The offending line is :
#include <iostream.h>

It tell you that <iostream.h> is a pre-standard form, and you must use
<iostream> instead.

Find a more recent C++ book or tutorial than you have actually.

Regards.
 
M

Mike Wahler

skumar said:
I am a newbie with C++ and unable to understand this warning/error
message :

localhost > g++ -Wall j++.cpp
In file included from /usr/include/c++/3.2.2/backward/iostream.h:31,
from j++.cpp:2:
/usr/include/c++/3.2.2/backward/backward_warning.h:32:2: warning:
#warning This file includes at least one deprecated or antiquated
header.

This is true. <iostream.h> is a header from before
C++ was standardized. So it's 'antiquated' rather
than 'deprecated'. 'Deprecated' means it's still
officially standard, but that a more 'modern' form
is preferred.

In standard C++, none of the standard headers (except
for some C library headers which are deprecated), have
a ".h" in their names. The *only* valid standard header
for declaring the standard stream objects is <iostream>.
No. '.h'.

All the identifiers in the C++ library (except macros
and C identifiers declared in the deprecated '.h' headers)
are declared inside namespace 'std', so you need to qualify them
when using them (with 'using' directives or declarations,
or explicit qualification).
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 <sstream> instead of
the deprecated header <strstream.h>.

This is what you need to do.
Change <iostream.h> to <iostream>, and get the
identifiers from namespace 'std'.

BTW That last part of the warning message is technically
incorrect. <strstream.h> is not and never has been part
of standard C++, so it cannot be 'deprecated'.

Many implemenations provide prestandard headers such
as <iostream.h> for 'backward compatibility' do that
legacy code can still be used. New code should use
the standard headers.

To disable this warning use
-Wno-deprecated.

The offending line is :
#include <iostream.h>

The compiler is GNU C/C++ version : 3.2.2.3
Host OS is : Mandrake Linux 9.1

All help welcome....

#include <iostream>
using namespace std; /* only use this form for simple */
/* or example programs */
int main()
{
cout << "Hello standard C++\n";
return 0;
}

More about this issue can be seen in a good (modern)
C++ text, and in the C++ FAQ:
http://www.parashift.com/c++-faq-lite/
See item 27.4 (But read the whole FAQ, you'll
be glad you did. :) )

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top