Solved

Problem with template classes in DLLs

Posted on 1998-02-24
2
217 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

809 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