Дабы не осталось непоняток:
Код:
[hasherfrog@********* hasherfrog]$ more 1.cpp
#include <iostream>
main() {
cout << "Hello, world\n";
}
[hasherfrog@********* hasherfrog]$ more 1.c
#include <iostream.h>
main() {
cout << "Hello, world\n";
}
[hasherfrog@********* hasherfrog]$ more correct.cpp
#include <iostream>
using namespace std;
main() {
cout << "Hello, world\n";
}
[hasherfrog@********* hasherfrog]$ more with_keys.cpp
#include <iostream.h>
main() {
cout << "Hello, world\n";
}
Компилим
Код:
[hasherfrog@********* hasherfrog]$ g++ 1.c
In file included from /usr/include/c++/3.2.2/backward/iostream.h:31,
from 1.c:1:
/usr/include/c++/3.2.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
[hasherfrog@********* hasherfrog]$ g++ 1.cpp
1.cpp: In function `int main()':
1.cpp:4: `cout' undeclared (first use this function)
1.cpp:4: (Each undeclared identifier is reported only once for each function it
appears in.)
[hasherfrog@********* hasherfrog]$ gcc 1.cpp
1.cpp: In function `int main()':
1.cpp:4: `cout' undeclared (first use this function)
1.cpp:4: (Each undeclared identifier is reported only once for each function it
appears in.)
[hasherfrog@********* hasherfrog]$ gcc 1.c
1.c:1:22: iostream.h: No such file or directory
1.c: In function `main':
1.c:3: `cout' undeclared (first use in this function)
1.c:3: (Each undeclared identifier is reported only once
1.c:3: for each function it appears in.)
[hasherfrog@********* hasherfrog]$ gcc correct.cpp
/tmp/ccrilZvg.o(.text+0x19): In function `main':
: undefined reference to `std::cout'
/tmp/ccrilZvg.o(.text+0x1e): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccrilZvg.o(.text+0x4a): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccrilZvg.o(.text+0x79): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccrilZvg.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
[hasherfrog@********* hasherfrog]$ g++ correct.cpp
[hasherfrog@********* hasherfrog]$
[hasherfrog@********* hasherfrog]$ g++ 1.c -Wno-deprecated
[hasherfrog@********* hasherfrog]$
[hasherfrog@********* hasherfrog]$ g++ with_keys.cpp -Wno-deprecated
[hasherfrog@********* hasherfrog]$