Solved

Problem with template classes in DLLs

Posted on 1998-02-24
2
215 Views
Last Modified: 2011-10-03
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
Comment
Question by:jmaresca
  • 2
2 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 20 total points
ID: 1182765
You need to declate the base class (template class) as __declspec(dllexport).
0
 
LVL 22

Expert Comment

by:nietod
ID: 1182766
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now