Link to home
Start Free TrialLog in
Avatar of lzha022
lzha022

asked on

VC6 DLL export of a class - warning C4251

Hello Experts,

I am creating a DLL.  In this DLL, i have a class named 'Model' that gets exported, and another class 'Transform' used in the class 'Model'. I do not want to export this class 'Transform' as it will not be used outside the DLL, but i got warnings like this:

warning C4251: 'tran' : class 'Transform' needs to have dll-interface to be used by clients of class Model'
Any one please tell me can i just ignore those warnings, or i have to export the class 'Transform'?

Regards,
Alison
Avatar of abancroft
abancroft

Is Transform referenced in the declaration of class Model? i.e. in the Model header file.
Avatar of lzha022

ASKER

Yes, in deader declared as Transform tran;
I think that is the reason of the warnings.
It is. Even if it's private or protected.

To completely hide it, you'd need to use the pimpl idiom: http://c2.com/cgi/wiki?PimplIdiom
Avatar of lzha022

ASKER

My project is too big, and there are more same warnings for other classes too. I can not afford to change all of them. All i want to know is that will this affect the functionality of my DLL if i just ignore those warnings.

It depends - is Transform declared entirely inline, or are some parts of it in a CPP file in your DLL? External users of class Model may need to call some transform methods indirectly. e.g. constructor, assignment operator etc. It really depends on how Transform is declared and how it is used in Model.
Avatar of lzha022

ASKER

is Transform declared entirely inline, or are some parts of it in a CPP file in your DLL? - I am not quite sure what you mean here.
protected:
Transform tran
Is the Transform class all inline? i.e. is all it's code in it's header file.
Avatar of lzha022

ASKER

...Continued:
class Model or some other classes will call tran.methods
So it is true that when use call Model it will inderectly call the Constructor of Transform and other mothods - but i think those all happen within the DLL.
Avatar of lzha022

ASKER

Is the Transform class all inline? No, it is a complete class
ASKER CERTIFIED SOLUTION
Avatar of abancroft
abancroft

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lzha022

ASKER

Thanks, I will try it
Avatar of lzha022

ASKER

Looks like it works