Solved

Problem with template classes in DLLs

Posted on 1998-02-24
2
214 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
Comment Utility
You need to declate the base class (template class) as __declspec(dllexport).
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

763 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

15 Experts available now in Live!

Get 1:1 Help Now