Bug 77667 - g++ will not compile
g++ will not compile
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
8.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-11-11 14:30 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-11 14:30:53 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-11 14:30:47 EST
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 15:05:50 EST
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.