depreciated libraries

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

depreciated libraries

Postby alloydog » Fri Jun 23, 2006 11:15 am

I posted this one before, ages ago, but it looks as if it has been cleared out, as the forum posts don't seem to go back that far.

Anyway, When I used Xwpe to compile Helloworld.cpp, I got a wordy warning about the library used, in this case iostream.h being depreciated.

I am using "Teach Yourself C++ in 21 Days", which is a few years old.

So, what libraries should I be using?
User avatar
alloydog
LXF regular
 
Posts: 600
Joined: Thu Apr 07, 2005 7:32 pm

RE: depreciated libraries

Postby Gordon » Fri Jun 23, 2006 4:04 pm

This warning means that you have used the declaration
Code: Select all
#include <iostream.h>

inside your source file but for proper C++ you neead to use
Code: Select all
#include <iostream>

For the proper (2nd) method to work correctly you may also need to use the statement
Code: Select all
using namespace std;

somewhere near the beginning of your code and also call the compiler with
Code: Select all
g++ -o helloworld Helloworld.cpp


Are you using "Teach Yourself C++ in 21 days" or "Teach yourself C++ for linux in 21 days"?
Violence is the last refuge of the incompetent
User avatar
Gordon
LXF regular
 
Posts: 209
Joined: Thu Apr 07, 2005 5:01 pm
Location: Bradford, West Yorkshire

RE: depreciated libraries

Postby alloydog » Fri Jun 23, 2006 7:08 pm

The full warning is:
Code: Select all
#ifdef __DEPRECATED
#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> heqader for the >X.h> \
header for C++ includes, or <sstream> instead of the deprecated header \
<strstream.h>  To diasble this warning use -Wno-deprecated.
#endif
I tried using just <iostream>, but I then got a different warning.
I think <iostream> has been replaced with something different.

Using <iostream.h>, the programme still compiled and ran OK.

I am using the "Teach Yourself C++ in 21 days".
User avatar
alloydog
LXF regular
 
Posts: 600
Joined: Thu Apr 07, 2005 7:32 pm

RE: depreciated libraries

Postby GMorgan » Sat Jun 24, 2006 1:17 am

iostream is the central input and output header for C++, its crucial to most C++ programs. You could use cstdio or stdio.h* but that is orignal C rather than C++. Your using Ubuntu aren't you, have you tried sudo apt-get install build-essential, it should ensure that your uptodate with the libraries.

*the original C headers used the .h notation. In C++ they dropped the .h. C++ also included original C functions repacked for C++ but with c in front of the original name. Hence stdio.h becomes cstdio, they both perform the same functions. iostream should work though and is the standard way of doing things in C++.
GMorgan
LXF regular
 
Posts: 684
Joined: Thu Jan 12, 2006 6:58 pm
Location: South Wales, UK

RE: depreciated libraries

Postby Gordon » Sun Jun 25, 2006 9:12 am

What warning did you get when you used the <iostream> declaration?
Violence is the last refuge of the incompetent
User avatar
Gordon
LXF regular
 
Posts: 209
Joined: Thu Apr 07, 2005 5:01 pm
Location: Bradford, West Yorkshire


Return to Programming

Who is online

Users browsing this forum: Google [Bot] and 1 guest