Beginning C++ in FreeBSD

Sergey Zaharchenko doublef at tele-kom.ru
Tue Apr 27 09:07:49 PDT 2004


On Tue, Apr 27, 2004 at 02:41:33PM +0200,
 Dag-Erling SmЬrgrav probably wrote:
> Sergey Zaharchenko <doublef at 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;
> 
> Sure:
> 
> void a(void)
> {
>         cout = endl = 0;
> }
> 
> 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()'")
> 

Script started on Tue Apr 27 20:01:30 2004
df at Shark:~> cat >cc.cc
#include <iostream>
class A
{
public:
        A();
};
A::A()
{
        cout<<"This shared library was loaded!"<<endl;
}
static A a;
df at Shark:~> g++ cc.cc
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x82): undefined reference to `main'
df at Shark:~> cat >c.c
void a(void)
{
        cout = endl = 0;
}
df at 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 at Shark:~>
df at 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...

-- 
DoubleF
Bare feet magnetize sharp metal objects so they point upward from the
floor -- especially in the dark.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-chat/attachments/20040427/3b459cc5/attachment.bin


More information about the freebsd-chat mailing list