Bug 77483 - Cannot compile Hello app with c++ using cout
Cannot compile Hello app with c++ using cout
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
8.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-11-07 15:21 EST by Need Real Name
Modified: 2007-04-18 12:48 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-11-07 15:21:56 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2002-11-07 15:21:49 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 
1.0.3705)

Description of problem:
cannot compile simple hello world app in c++ using gcc and the 3.2 iostream 
header

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.Gedit  
2.#include <iostream>
int main()
{
cout <<"hello world");
return 0;
}
3. Save as test.c
4. gcc test.c

Actual Results:  Return=  test.c:1:21:  iostream No such file or directory
test.c: In function 'main':
test.c:4: 'cout' undeclared (first us in this function)
Etc.... 

Expected Results:  My thought is that the code should compile and that 
somewhere the headers are confused.

Additional info:

I have explored with gcc -B   and cpp -I   etc.  to try and get the headers to 
respond correctly we can get the app to compile using C++ and mapping to the 
backwards directory and using <iostream.h> but that is not the desired method 
and comes with an error etc.
Comment 1 Jakub Jelinek 2002-11-07 15:25:38 EST
This is a C++ program, right? So it should use .C/.cxx/.cpp/.c++ extension, not .c.
Also, if you are using STL in it, you should use g++ compiler driver, not gcc,
so that libstdc++ gets linked in.
And last, cout is in std namespace, so you need to write std::cout
or add using namespace std; or using std::cout; above main.

Note You need to log in before you can comment on or make changes to this bug.