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:
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