Link to home
Start Free TrialLog in
Avatar of jmaresca
jmaresca

asked on

Problem with template classes in DLLs

Hi,

  Does anyone know how I can get rid of this warning:

warning C4275: non dll-interface class 'ntfNotificationServer<enum ivNOTIFY_TYPE>' used as base for dll-interface class 'imageView'

The problem that I'm having is that the base class is a template class defined in a separate header file with no linkage specification:

template <class T> class ntfNotificationServer {...}

And used as a base for a class exported by the dll:

class ivDLLEXPORT imageView : public CView, public ivNotificationServer
{...}

ivDLLEXPORT is just a macro used to control dllimport/dllexport for .h & .cpp files.

I get the same warning from CView, but I can get rid of this one by predeclaring it like so:

class __declspec(dllimport) CView;

Unfortunately, if I do this for the template class, I have problems with inconsistant linkage for the member functions.

Thanks for any help,
Jerry
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nietod
nietod

Try

template <class T> class DllExport ntfNotificationServer {...}

class ivDLLEXPORT imageView : public CView, public
ivNotificationServer
{...}

I assume you are indicating what type that ntfNotificationServer shoudl be expanded for in ImageView.  Right?  If not that is a problem.