Gentoo Archives: gentoo-dev

From: "Thomas T. Veldhouse" <veldy@×××××.net>
To: Spider <spider@g.o>
Cc: gentoo-dev@g.o
Subject: Re: [gentoo-dev] Need some c++ help here please:
Date: Mon, 26 Aug 2002 22:11:55
Message-Id: 200208262211.56163.veldy@veldy.net
In Reply to: [gentoo-dev] Need some c++ help here please: by Spider
1 The standard way to do it these days is to use the standard library, which is
2 in the standard namespace.
3
4 You should probably only use the parts of the standard namespace that you need
5 to avoid namespace collisions. So ...
6
7 #include <iostream>
8 using std::cout;
9 using std::endl;
10 // you could comment out the above to lines if you are lazy and uncomment
11 // the following line
12 // using namespace std;
13
14 int main(int, char**) {
15 cout << "Hello World" << endl;
16 return 0;
17 }
18
19 Tom Veldhouse
20 veldy@×××××.net
21
22 On Monday 26 August 2002 09:42 am, Spider wrote:
23 > cat hiworld.cpp
24 > #include <iostream.h>
25 > int main(){
26 > cout << "Hello World" << endl;
27 > return(0);
28 > }
29 >
30 >
31 > Old standard, but should work afaik...
32 >
33 > gcc -dumpversion
34 > 3.2
35 >
36 > c++ -dumpversion
37 > 3.2
38 >
39 >
40 >
41 > spider@Darkmere> gcc -o hiworld hiworld.cpp
42 > In file included from /usr/include/g++-v32/backward/iostream.h:31,
43 > from hiworld.cpp:1:
44 > /usr/include/g++-v32/backward/backward_warning.h:32:2: warning: #warning
45 > This file includes at least one deprecated or antiquated header. Please
46 > consider using one of the 32 headers found in section 17.4.1.2 of the
47 > C++ standard. Examples include substituting the <X> header for the <X.h>
48 > header for C++ includes, or <sstream> instead of the deprecated header
49 > <strstream.h>. To disable this warning use -Wno-deprecated.
50 > /tmp/ccKgk3Jj.o: In function `main':
51 > /tmp/ccKgk3Jj.o(.text+0x13): undefined reference to `std::cout'
52 > /tmp/ccKgk3Jj.o(.text+0x20): undefined reference to
53 > `std::basic_ostream<char, std::char_traits<char> >& std::operator<<
54 > <std::char_traits<char> >(std::basic_ostream<char,
55 > std::char_traits<char> >&, char const*)'
56 > /tmp/ccKgk3Jj.o(.text+0x2b): undefined reference to
57 > `std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
58 > std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char>
59 >
60 > >&)'
61 >
62 > /tmp/ccKgk3Jj.o(.text+0x30): undefined reference to
63 > `std::basic_ostream<char, std::char_traits<char>
64 >
65 > >::operator<<(std::basic_ostream<char, std::char_traits<char> >&
66 > >
67 > >(*)(std::basic_ostream<char, std::char_traits<char> >&))'
68 >
69 > /tmp/ccKgk3Jj.o: In function
70 > `__static_initialization_and_destruction_0(int, int)':
71 > /tmp/ccKgk3Jj.o(.text+0x59): undefined reference to
72 > `std::ios_base::Init::Init[in-charge]()'
73 > /tmp/ccKgk3Jj.o: In function `__tcf_0':
74 > /tmp/ccKgk3Jj.o(.text+0x8a): undefined reference to
75 > `std::ios_base::Init::~Init [in-charge]()'
76 > /tmp/ccKgk3Jj.o(.eh_frame+0x11): undefined reference to
77 > `__gxx_personality_v0'
78 > collect2: ld returned 1 exit status
79 >
80 > spider@Darkmere> c++ -o hiworld hiworld.cpp
81 > /tmp/dd
82 > In file included from /usr/include/g++-v32/backward/iostream.h:31,
83 > from hiworld.cpp:1:
84 > /usr/include/g++-v32/backward/backward_warning.h:32:2: warning: #warning
85 > This file includes at least one deprecated or antiquated header. Please
86 > consider using one of the 32 headers found in section 17.4.1.2 of the
87 > C++ standard. Examples include substituting the <X> header for the <X.h>
88 > header for C++ includes, or <sstream> instead of the deprecated header
89 > <strstream.h>. To disable this warning use -Wno-deprecated.
90 >
91 >
92 >
93 >
94 > But this works.... .
95 >
96 > Now.. what am I missing here???
97 >
98 > //Spider