Private Virtual Functions.

Login to reply to this topic.
Wed, 2008-02-20 16:37
Joined: 2008-02-13
Forum posts: 6

Hi,

I dont know how silly this question might be, but i am getting
really mad trying to fix this linker error. Following is the prblm:
class REikAppServiceBase : public RApaAppServiceBase
{
........
private:
IMPORT_C virtual void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion);
.........
};

class RTestServ : public REikAppServiceBase
{
.......
private:
IMPORT_C void ExtensionInterface(TUid /*aInterfaceId*/, TAny*& /*aImplementaion*/);
.......
};

class RScriptTestServ : public RTestServ
{
.......
private:
IMPORT_C void ExtensionInterface(TUid /*aInterfaceId*/, TAny*& /*aImplementaion*/);
.......
};
.................................................................................................................................

The function is implemented in all the classes also all three classes are in separate dlls.
All functions are implemented as:

EXPORT_C void classname::ExtensionInterface(TUid /*aInterfaceId*/, TAny*& /*aImplementaion*/)
{

}
All the respective .def files are appropriately updated, also the last 2 classes are my implementation. base class by symbian

When i compile this, i get a linker error:
mwldsym2.exe: Undefined symbol: 'void
REikAppServiceBase::ExtensionInterface(class TUid, void * &)
(?ExtensionInterface@REikAppServiceBase@@EAEXVTUid@@AAPAX@Z)'
mwldsym2.exe: referenced from 'const REikAppServiceBase::`vftable'
(??_7REikAppServiceBase@@6B@~)' in file (where class RScriptTestServ is
implemented).

I dont understand why the vftable of REikAppServiceBase in RScriptTestServ class file point to a function which is private.?
And if so, why did they export that function?

Thanks in Advacne,
Sanath.


Thu, 2008-02-21 08:27
Joined: 2003-09-29
Forum posts: 32
Re: Private Virtual Functions.

Hi,

The ExtensionInterface function is not pure virtual in the base class, so you should not even implement it in your derived class if you don't know what it should do. Basically it is a place for the platform developers to extend the base class without breaking binary compatibility.

The reason why the virtual function is exported from the class is that if derived classes implement the virtual function, they probably should call the base class implementation from their implementation. In that case call would be REikAppServiceBase::ExtensionInterface(aInterfaceId, aImplementation) which will be resolved statically instead of being a virtual function call. Because the call is resolved statically, it does not go through the virtual function calling mechanism, and that is why the virtual function must be in the DLL interface as well.

In any case, I think you have to link against the lib file that defines REikAppServiceBase, because you will need its constructor and destructor from there.


Jari

Thu, 2008-02-21 09:42
Joined: 2008-02-13
Forum posts: 6
Re: Private Virtual Functions.

Hi Jari,

This is exactly what i had thought when writing the classes RTestServ and RScriptTestServ. I dint even bother abt the function. But it still gived me the same linker error "Undefined symbol: 'void REikAppServiceBase::ExtensionInterface...." along with 2 other errors "Undefined symbol: void RTestServ ::ExtensionInterface" and "Undefined symbol: void RScriptTestServ ::ExtensionInterface" in the file where RScriptTestServ is defined. Thats why i had to implement that function and export it in my 2 classes. So the last 2 errors were resolved but then the first one remains again. The weird thing is how can the vftable of REikAppServiceBase in RScriptTestServ class file point to a function that is private in the base class. Do you think its possible? or a design issue with class?

Thu, 2008-02-21 17:30
Joined: 2008-02-13
Forum posts: 6
Re: Private Virtual Functions.

It compiles for armv5 urel. Not for emulator . May be emulator linker is screwed?

  • Login to reply to this topic.