Bug 77667
| Summary: | g++ will not compile | ||
|---|---|---|---|
| Product: | [Retired] Red Hat Linux | Reporter: | Need Real Name <t-anderson> |
| Component: | gcc | Assignee: | Jakub Jelinek <jakub> |
| Status: | CLOSED NOTABUG | QA Contact: | Brian Brock <bbrock> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 8.0 | ||
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2002-11-11 19:30:53 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
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 |
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: