I have this peculiar problem with g++ under linux. This is a small piece of code that i wrote #include<iostream.h> main() { cout << "blahblah"; }
When i try to compile it, i get the following warning
In file included from /usr/include/c++/3.2/backward/iostream.h:31, from first.cpp:1: /usr/include/c++/3.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.
To get a warning free compile i commented out the line
#include backward_warning from iostream.h
When i try to run the executable the shell does a silent return, without printing the blahblah as it is supposed to. I redirected the output to a file, and it contained blahblah. I dont think the problem is with g++, but i cant exactly put my finger on it. Any pointers would be gratefully acknowledged Sankha
On Sun, 9 Feb 2003, Sankha Subhra Som wrote:
I have this peculiar problem with g++ under linux. This is a small piece of code that i wrote #include<iostream.h> main() { cout << "blahblah"; }
When i try to compile it, i get the following warning In file included from /usr/include/c++/3.2/backward/iostream.h:31, from first.cpp:1: /usr/include/c++/3.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.
To get a warning free compile i commented out the line #include backward_warning from iostream.h
This is not required.
Your program should look like this, ----------------------------------------------------------------- #include <iostream> /* <X> replaces <X.h> */ using namespace std; /* lets use standard cout */
main() { cout << "blahblah\n"; /* \n to get this printed properly */ } -----------------------------------------------------------------
When i try to run the executable the shell does a silent return, without printing the blahblah as it is supposed to.
The "blahblah" is being overwritten by your shell prompt, "\n" at the end will avoid this overwriting.
HTH,
Rajesh
Sankha Subhra Som writes:
I have this peculiar problem with g++ under linux. This is a small piece of code that i wrote #include<iostream.h> main() { cout << "blahblah"; }
When i try to compile it, i get the following warning
[snip]
IMHO the o/p is unrelated to g++.
from the stdout man pages stdout is line buffered when associated with a terminal, stderr is unbuffered, stdin is generally line buffered. Modify your program as follows and it will work fine. It will give the same warning as above.
<code> #include<iostream.h> main() { cout << "blahblah" << endl ; ^^^^^^^^^ } </code>
Also try out the following two programs which illustrate the point the buffering funda.
<code> #include <stdio.h> main() { printf("hello world"); } </code>
On redirecting to a file the program is working fine(you see the o/p). Files are full buffered. file buffers are flushed when the program exits, the same is not true of stdout. However fflush can be used to flush the buffers. Also sometimes sync() can do the trick. how ever the program run the command line does not print anything. Now try this modified program.
<code> #include <stdio.h> main() { printf("hello world\n"); ^^ } </code>
Note the \n which flushes the line buffer.
When i try to run the executable the shell does a silent return, without printing the blahblah as it is supposed to. I redirected the output to a file, and it contained blahblah. I dont think the problem is with g++, but i cant exactly put my finger on it.
I hope that answers your question.
Vinayak Hegde APGDST Student NCST-JUHU
vinayak_hegde@softhome.net writes:
Files are full buffered. file buffers are flushed when the program exits, the same is not true of stdout. However fflush can be used to flush
^^^^^^^^ Please correct the above. The same is true of stdout. ^^^^ Vinayak Hegde APGDST Student NCST-JUHU
Sankha Subhra Som wrote:
I have this peculiar problem with g++ under linux. This is a small piece of code that i wrote #include<iostream.h>
Make this <iostream>
Drop the .h. It's deprecated.
main() { cout << "blahblah"; }
cout is in the std namespace. So either you declare that you're using the namespace or you qualify cout with the namespace name. e.g.
std::cout << "blahblah";
To get a warning free compile i commented out the line
#include backward_warning from iostream.h
You don't need to screw with the standard library headers just to get your program to compile!
When i try to run the executable the shell does a silent return, without printing the blahblah as it is supposed to. I redirected the output to a file, and it contained blahblah.
Just guessing -- you probably need to flush the output stream. Appending an std::endl at the end should do it.
-mj
On Sun, 9 Feb 2003, Sankha Subhra Som wrote:
#include<iostream.h>
[snip]
When i try to compile it, i get the following 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.
You know what bugs me here? That people have started using this list as a cheap means of reading self explanatory error messages. The above error message is short and easy to understand. Did you even read it before posting to this list?
Philip
On Sun, 9 Feb 2003, Sankha Subhra Som wrote:
I think this is a particular problem with iit kgp compiler...:)
I have this peculiar problem with g++ under linux. This is a small piece of code that i wrote #include<iostream.h> main() { cout << "blahblah"; }
When i try to compile it, i get the following warning
In file included from /usr/include/c++/3.2/backward/iostream.h:31, from first.cpp:1: /usr/include/c++/3.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.
To get a warning free compile i commented out the line
#include backward_warning from iostream.h
When i try to run the executable the shell does a silent return, without printing the blahblah as it is supposed to. I redirected the output to a file, and it contained blahblah. I dont think the problem is with g++, but i cant exactly put my finger on it. Any pointers would be gratefully acknowledged Sankha
On Sun, Feb 09, 2003 at 07:46:54PM +0530, harsh wrote:
On Sun, 9 Feb 2003, Sankha Subhra Som wrote:
I think this is a particular problem with iit kgp compiler...:)
no.
that compiler is proper ( gcc 3.2 as they mention ). It's just that C++ standards are not being followed in the submitted programs.
I have this peculiar problem with g++ under linux. This is a small piece of code that i wrote #include<iostream.h> main() { cout << "blahblah"; }
<snip>
But, where is that contest mentioned in this mail?
Nevertheless ...