Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

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
0
jmaresca
Asked:
jmaresca
  • 2
1 Solution
 
nietodCommented:
You need to declate the base class (template class) as __declspec(dllexport).
0
 
nietodCommented:
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.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now