Re: Re: C++ extension question

From: Date: Wed, 17 Sep 2003 15:05:37 +0000
Subject: Re: Re: C++ extension question
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-4513@lists.php.net to get a copy of this message
No, that only prevents the file being included twice in the same .cpp file. The solution to this problem is to move the function bodies into their own .cpp file: foo.h: class Foo { Foo(); ~Foo(); }; fooclass.cpp: Foo::Foo() { ... } Foo::~Foo() { ... } --Wez. ----- Original Message ----- From: "Igal Ore" <iore@cipherquest.com> To: <internals@lists.php.net>; "Wez Furlong" <wez@thebrainroom.com> Cc: <jay@php.net>; <internals@lists.php.net> Sent: Wednesday, September 17, 2003 4:01 PM Subject: Re: [PHP-DEV] Re: C++ extension question > you are right , and for those cases there a preprocessor protection > #ifndef DO_NOT_MAKE_BOBO > #define DO_NOT_MAKE_BOBO > > class Foo{ > Foo(){...} > ~Foo(){...} > }; > #endif > > > isn't it? > > Wez Furlong wrote: > > This sounds like the "rookie" mistake of declaring your functions inline in > > the class definition in the header files, and then including those headers > > in multiple files. > > > > eg: foo.h: > > > > class Foo { > > Foo() { ... } > > ~Foo() { ... } > > }; > > > > foo.cpp: > > #include "foo.h" > > > > bar.cpp: > > #include "foo.h" > > > > == linker problems. > > > > --Wez.

« previous php.internals (#4513) next »