Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pure base class needs to be exported from DLL?

I have two DLLs: a.dll and b.dll and in each one I have one class AClass and BClass.
I would like to have both AClass and BClass inherit and implement the same interface AbsBase which is a pure abstract class.
In each class I set up the #defines for __declspec(dllimport) and __declspect(dllexport). When I'm trying to compile I get this:

warning C4275: non dll-interface class 'AClass' used as base for dll-interface class 'AbsBase'

which basically wants me to declare AbsBase as __declspec(dllexport)
But if the compiler would have it his way, I would have to declare AbsBase to be exported from both a.dll and b.dll.

Why does the interface of a class needs to be exported?
Is there any way around it? Should I really export AbsBase from both DLLs? isn't there something inherently wrong with this? (I would need to define a new XXX_EXPORT macro..)

like image 542
shoosh Avatar asked Oct 15 '22 10:10

shoosh


1 Answers

It looks like its a compiler warning and not an error, so it should still work. The compiler is just letting you know that you are doing something that makes it easy for you to screw up. It should be perfectly acceptable to do this as long as both DLLs and the core program agree on the definition of the base class.

You should be able to use a pragma to supress the warning:

http://forums.devx.com/archive/index.php/t-84785.html

like image 91
bdk Avatar answered Nov 03 '22 05:11

bdk