Re: Beginning C++ in FreeBSD

看板FB_chat作者時間22年前 (2004/04/28 08:08), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串27/43 (看更多)
--wac7ysb48OaltWcw Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 27, 2004 at 02:41:33PM +0200, Dag-Erling Sm=D0=ACrgrav probably wrote: > Sergey Zaharchenko <doublef@tele-kom.ru> writes: > > // Turing strikes again:) > > // Ok. Write this (to be compiled as a shared object) in portable C: > > > > #include <iostream> > > > > class A > > { > > public: > > A(); > > }; > > > > A::A() > > { > > cout<<"This shared library was loaded!"<<endl; > > } > > > > static A a; >=20 > Sure: >=20 > void a(void) > { > cout =3D endl =3D 0; > } >=20 > the error message won't be *exactly* the same, but pretty close > (different line numbers, and "In function `a'" instead of "In > constructor `A::A()'") >=20 Script started on Tue Apr 27 20:01:30 2004 df@Shark:~> cat >cc.cc #include <iostream> class A { public: A(); }; A::A() { cout<<"This shared library was loaded!"<<endl; } static A a; df@Shark:~> g++ cc.cc /usr/lib/crt1.o: In function `_start': /usr/lib/crt1.o(.text+0x82): undefined reference to `main' df@Shark:~> cat >c.c void a(void) { cout =3D endl =3D 0; } df@Shark:~> c89 c.c c.c: In function `a': c.c:3: `cout' undeclared (first use in this function) c.c:3: (Each undeclared identifier is reported only once c.c:3: for each function it appears in.) c.c:3: `endl' undeclared (first use in this function) df@Shark:~> df@Shark:~> exit exit Script done on Tue Apr 27 20:03:34 2004 Sorry? I mean, you've got the object file, and can compile a shared library which will advertize itself, with the former, whereas the latter, as you've pointed out, doesn't compile. A quick hint: Turing has nothing to do with all this... --=20 DoubleF Bare feet magnetize sharp metal objects so they point upward from the floor -- especially in the dark. --wac7ysb48OaltWcw Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAjoVIwo7hT/9lVdwRAqNHAJ0SF7hC4f1dzYw9snUuGHxwSi6sawCfX/os Kt0bQtay0j+yfEPYUSyIAPc= =QLPt -----END PGP SIGNATURE----- --wac7ysb48OaltWcw--
文章代碼(AID): #10ZlNb00 (FB_chat)
討論串 (同標題文章)
文章代碼(AID): #10ZlNb00 (FB_chat)