Bug 77667 - g++ will not compile
Summary: g++ will not compile
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 8.0
Hardware: All
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-11 19:30 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-11 19:30:53 UTC
Embargoed:


Attachments (Terms of Use)

Description Need Real Name 2002-11-11 19:30:47 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020830

Description of problem:
g++  will not compile a simple hello world.
Script started on Mon Nov 11 14:23:09 2002
]0;Tom@localhost:~[Tom@localhost Tom]$ g++   ccat   c
at tesst  s  t.c   st.cxx
#include <iostream>

void main()
{
cout << "hello world"<< endl;
}]0;Tom@localhost:~[Tom@localhost Tom]$ g++ test.cxx
test.cxx:4: `main' must return `int'
test.cxx: In function `int main(...)':
test.cxx:5: `cout' undeclared (first use this function)
test.cxx:5: (Each undeclared identifier is reported only once for each function 
   it appears in.)
test.cxx:5: `endl' undeclared (first use this function)
test.cxx:6:2: warning: no newline at end of file
]0;Tom@localhost:~[Tom@localhost Tom]$ exit

Script done on Mon Nov 11 14:23:30 2002


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


How reproducible:
Always

Steps to Reproduce:
1.prepare hello world
2.compile
3.
	

Actual Results:  Script started on Mon Nov 11 14:23:09 2002
]0;Tom@localhost:~[Tom@localhost Tom]$ g++   ccat   c
at tesst  s  t.c   st.cxx
#include <iostream>

void main()
{
cout << "hello world"<< endl;
}]0;Tom@localhost:~[Tom@localhost Tom]$ g++ test.cxx
test.cxx:4: `main' must return `int'
test.cxx: In function `int main(...)':
test.cxx:5: `cout' undeclared (first use this function)
test.cxx:5: (Each undeclared identifier is reported only once for each function 
   it appears in.)
test.cxx:5: `endl' undeclared (first use this function)
test.cxx:6:2: warning: no newline at end of file
]0;Tom@localhost:~[Tom@localhost Tom]$ exit

Script done on Mon Nov 11 14:23:30 2002


Expected Results:  it should have allowed main to be void, recognized cout as
legitimate

Additional info:

Comment 1 Jakub Jelinek 2002-11-11 20:05:50 UTC
main must return int, ISO C++ 98 requires this.
cout nor endl are present in global namespace, so neither that can be recognized.
They are defined in std namespace, so you need either to:
a) add using namespace std; after the includes
b) add using std::cout; and using std::endl; after the includes
c) use std::cout instead of cout and similarly with endl


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