[Techtalk] iostream.h question (C++)

Dominik Schramm dominik.schramm at gmxpro.net
Sat Dec 13 13:21:07 EST 2003


Hi,

On 12/13/2003 07:45 AM, alice wrote:

>When I compile anything with:
>
>#include <iostream.h>
>
>I get the following message:
>
>/usr/include/g++/backward/backward_warning.h:32:2: warning: #warning This file 
>[...]
>

>Everything compiles okay, but I was wondering what I should include instead of 
><iostream.h> so as to not get this message.
>  
>

No genuine C++ header has a .h extension.
You should include <iostream>.

Just have a look at the files in /usr/include/g++/
E.g. my iostream says:
#ifndef __IOSTREAM__
#define __IOSTREAM__
#include <iostream.h>
#endif

so it in turn includes the file iostream.h, but defines __IOSTREAM__
(which is the GNU C++ way of remembering which headers have
already been included). iostream.h defines _IOSTREAM_H, which
is the GNU C way, for C++ the compatibility way.

Unfortunately I can't tell you when you get real problems
by including C headers in C++ files. But it may well be
that the .h files won't be part of the g++ distribution any more
some time in the future. Then all your programs which compile
with a warning now would fail completely.

>Also where abouts on the internet is the C++ standard kept?
>  
>

The C++ standard is an ISO document and not available for free.
A good chance of getting it is through the programming department
at university (when you're doing computer studies yourself or
know somehow who does).
Alternatively get a book on the subject,
e.g. "The C++ Programming Language" by Bjarne Stroustrup
(I recommend this book to advanced C++ programmers only
because it is *very* detailed.)

hope this helps
regards,
dominik





More information about the Techtalk mailing list