Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 77483 - Cannot compile Hello app with c++ using cout
Summary: Cannot compile Hello app with c++ using cout
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 8.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-11-07 20:21 UTC by Need Real Name
Modified: 2007-04-18 16:48 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-11-07 20:21:56 UTC


Attachments (Terms of Use)

Description Need Real Name 2002-11-07 20:21:49 UTC
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 20:25:38 UTC
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.