Archived

This forum has been archived. Please start a new discussion on GitHub.

Class inheritance problem

My problem is that I want to write a ChannelBase.ice which contains a
ChannelBase.ice
module MyNameSpace
{
class ChannelBase
{
void myOperation();
}
}

I generate a ChannelBase.cpp, and create a simple helper C functions to create a proxy to a ChannelBase server, and call the myOperation() on it. For this C file I need the ChannelBase.h and ChannelBase.obj.

Then I want to extend the ChannelBase class adding a new operation:

AdvChannelBase.ice
module MyNameSpace
{
class ChannelBase
{
void myOperation();
}
class AdvChannel extends ChannelBase
{
void myOtherOperation();
}
}

I want to create another helper C function to create an AdvChannel proxy and call the myOtherOperation() on it.

Compiling them generates 4 .obj files. That is easy. But I link these 4
obj-s together, the linker says, that (for example) the myOperation already defined ...

What is solution?

(sorry for my terrible english. I am a little bit tired now :( I hope the problem is clear... )

Comments

  • matthew
    matthew NL, Canada
    Re: Class inheritance problem
    Originally posted by aroan
    My problem is that I want to write a ChannelBase.ice which contains a

    ChannelBase.ice
    module MyNameSpace
    {
    class ChannelBase
    {
    void myOperation();
    }
    }

    I generate a ChannelBase.cpp, and create a simple helper C functions to create a proxy to a ChannelBase server, and call the myOperation() on it. For this C file I need the ChannelBase.h and ChannelBase.obj.

    Then I want to extend the ChannelBase class adding a new operation:

    AdvChannelBase.ice
    module MyNameSpace
    {
    class ChannelBase
    {
    void myOperation();
    }
    class AdvChannel extends ChannelBase
    {
    void myOtherOperation();
    }
    }

    I want to create another helper C function to create an AdvChannel proxy and call the myOtherOperation() on it.

    Compiling them generates 4 .obj files. That is easy. But I link these 4
    obj-s together, the linker says, that (for example) the myOperation already defined ...

    What is solution?

    (sorry for my terrible english. I am a little bit tired now :( I hope the problem is clear... )

    You should #include ChannelBase.ice in AdvChannelBase.ice instead of duplicating the definition of ChannelBase.

    Regards, Matthew
  • When I try to write

    #include <Channel.ice>
    module MyNameSpace
    {
    class AdvChannel extends ChannelBase
    {
    void myOtherOperation();
    }
    }
    ... I got "no include path in which to find Channel.ICE". It is odd, cause this file is in the current directory.

    when I use "slice2cpp -IDIR .\ AdvChannel.ICE" it says "input files must end with .ice"

    Any idea?
  • mes
    mes California
    If the included file is in the current directory, then you need to specify

    slice2cpp -I. AdvChannel.ice

    The DIR in the usage instructions for the -IDIR option is supposed to be replaced with a directory, as I've shown above.

    - Mark
  • Aham. That's working now. May be the form -I<DIR> would be more understable. And it is not clear why the actual directory is not in the include directory list by default. But after that it was my mistake :-)

    Thank you for your help.