LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C++ iostream - getting "deprecated header" error (https://www.linuxquestions.org/questions/programming-9/c-iostream-getting-deprecated-header-error-235980/)

jdruin 09-27-2004 07:47 PM

C++ iostream - getting "deprecated header" error
 
I have a simple program I am using to explore typedef and structs more:

Code:

// /usr/include/c++/3.3/backward/iostream.h

#include <iostream.h>

typedef struct test_struct{
    int a;
    long b;
    char *c;
} *p_test;

int main(void){

    test_struct t;
    p_test p;
   
    p = &t;

    cout << "Size Of Struct: " << sizeof(test_struct) << " bytes" << std::endl;
   
    cout << "Address Of Struct: " << &t << std::endl;
   
    cout << "Size Of a: " << sizeof(t.a) << " bytes" << std::endl;
   
    cout << "Address Of a: " << &t.a << std::endl;   
   
    cout << "Size Of p: " << sizeof(p) << " bytes" << std::endl;
   
    cout << "Address Of p: " << &p << std::endl;   
   
    cout << "Contents Of p: " << p << std::endl;   
   
}


I compile with
Quote:

g++ -o hello -g hello.c
Then I get this warning:

/usr/include/c++/3.3/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.

I did a
Code:

find / -name iostream.h
and the only path that came up was /usr/include/c++/3.3/backward/iostream.h which is the very iostream that I linked to. Where is the "correct" iostream? Is it in some package? How does this work? Thanks.

itsme86 09-27-2004 07:53 PM

Just do #include <iostream> instead of #include <iostream.h>. It's not a matter of using the incorrect header, it's a matter of including the header correctly :)

michaelk 09-27-2004 07:56 PM

Futhermore add

using namespace std;

like :

#include <iostream>
#include <list>

using namespace std;

int main ()
{
....
}

jdruin 09-28-2004 07:31 AM

Thanks for the response. Could someone explain 'why' the declaration is incorrect and 'how' Linux utilizies these libraries. Also, is the iostream I found using the find function the one being used in the program? Where are Linux libraries usually stored. I am more interested in learning what is happening here rather than the syntax, although I appreciate the help on that too! Thanks.


All times are GMT -5. The time now is 05:52 PM.