Hey, I could work around this issue. Thanks for you help so far!!
If you are interested see below.
On 05/20/10 15:54, Marc Espie wrote:
> On Thu, May 20, 2010 at 03:18:39PM +0200, Christopher Zimmermann wrote:
> There's no gcc 3.5.
ok, that's true, its 3.3.5 of course.
>> std::string a(std::string(A::Class()));
>>
>> results in:
>> error: cannot use `::' in parameter declaration
>
> gcc 3.3.5 can't understand chains of constructors relying on temporaries,
> use intermediate variables.
I think I got that.
> e.g.,
>
> A::Class tmp;
> std:string a(tmp);
Class() is a method of every class in ptlib/opal, which just
returns a string as identifier for that class. (See below for the
code)
So declaring A::Class tmp does not really make sense, does it?
> (the double std::string is non-sensical, btw)
As I said, I tried to strip down the offending code as much as
possible to find out what the compiler is actually complaining
about. The original snippet of code looked like this:
======================== SNIP ===========================
#define OPAL_DEFINE_COMMAND(command, entity, func) \
class entity##_##command : public command \
{ \
public: virtual void Process(OpalPresentity & presentity) {
dynamic_cast<entity &>(presentity).func(*this); } \
}; \
static PFactory<OpalPresentityCommand>::Worker<entity##_##command> \
s_entity##_##command(PDefaultPFactoryKey(entity::Class())+typeid(command).name())
======================== SNIP ===========================
As I understand it now, the compiler would need to create a
temporary instance of 'entity' to make the call to ::Class(), but
gcc 3.3.5 is not able to do this?
I now tried to fix it this way:
======================== SNIP ===========================
#define OPAL_DEFINE_COMMAND(command, entity, func) \
class entity##_##command : public command \
{ \
public: virtual void Process(OpalPresentity & presentity) {
dynamic_cast<entity &>(presentity).func(*this); } \
}; \
entity tmp; \
static PFactory<OpalPresentityCommand>::Worker<entity##_##command> \
s_entity##_##command(PDefaultPFactoryKey(tmp.Class())+typeid(command).name())
OPAL_DEFINE_COMMAND(OpalSetLocalPresenceCommand, OpalPresentity,
Internal_SendLocalPresence);
======================== SNIP ===========================
this doesn't work because:
`OpalPresentity::OpalPresentity()' is protected
within this context cannot declare variable `tmp' to be of type
`OpalPresentity' because the following virtual functions are
abstract:
virtual bool OpalPresentity::Open()
virtual bool OpalPresentity::IsOpen() const
virtual bool OpalPresentity::Close()
> I'm willing to help, but can you at least double check what you type ?
Now anyway this is where the ::Class() method is defined:
======================== SNIP ===========================
#define PCLASSINFO(cls, par) \
public: \
typedef cls P_thisClass; \
static inline const char * Class() \
{ return #cls; } \
======================== SNIP ===========================
Since PCLASSINFO gets called with the 'OpalPresenty' as parameter
for 'cls' I could just remove the 'entity::Class()' thingy and
replace it by '#entity':
======================== SNIP ===========================
#define OPAL_DEFINE_COMMAND(command, entity, func) \
class entity##_##command : public command \
{ \
public: virtual void Process(OpalPresentity & presentity) {
dynamic_cast<entity &>(presentity).func(*this); } \
}; \
static PFactory<OpalPresentityCommand>::Worker<entity##_##command> \
s_entity##_##command(PDefaultPFactoryKey(#entity)+typeid(command).name())
======================== SNIP ===========================
grrrr, that was too easy. I tried to fix this for several days
now. Sometimes you just need to know where to look.
Anyway thank you very much for your inspiration ;)
Cheers,
Christopher