Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Apr 2004 20:07:37 +0400
From:      Sergey Zaharchenko <doublef@tele-kom.ru>
To:        Dag-Erling =?utf-8?B?U23QrHJncmF2?= <des@des.no>
Cc:        chat@freebsd.org
Subject:   Re: Beginning C++ in FreeBSD
Message-ID:  <20040427160737.GA1325@Shark.localdomain>
In-Reply-To: <xzphdv5wq2q.fsf@dwp.des.no>
References:  <20040425215837.3f4708fe.cpressey@catseye.mine.nu> <20040426094335.GA7578@online.fr> <20040426115842.GA4144@Shark.localdomain> <xzphdv5wq2q.fsf@dwp.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040427160737.GA1325>