DEFINE_HSEQUENCE in DLL (How to define __declspec?)

Hello,

I am working on an application consisting of several modules, each of them forming a DLL file. Now in one class of one module I would like to define a new container type using

DEFINE_HSEQUENCE(MyClassSequence, NCollection_Sequence).

The problem is now that I get linker errors when compiling another DLL that is linked agains the DLL containing this new container. The linker sais, that there is an undefined reference to the vtable of MyClassSequence. This is true. I should add __declspec(dllexport) to the class definition of the sequence. But unfortunately the DEFINE_HSEQUENCE macro offers no possibility to add the __declspec keyword.

I would have to copy and paste the definition into my source code and insert __declspec in this copy. I hate things like that! :-(

Is this a bad style definition of DEFINE_HSEQUENCE or is there a workaround? No nice solution came to my mind.

If anyone could help me with that I would be glad and thankful! :-)

Bye,
Benjamin

Forum supervisor's picture

Dear Benjamin,

DEFINE_HSEQUENCE() is a legacy way to declare a sequence manipulated by Handle.
More convenient alternative to it is use of NCollection_Shared template:

typedef NCollection_Shared<NCollection_Sequence<SomeType> >  HSequenceOfSomeType;
...
Handle(HSequenceOfSomeType) aSeq = new HSequenceOfSomeType;

Here SomeType can be either plain class or a Handle, this does not matter.
 

Best regards
FSR