[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VC6 DLL export of a class - warning C4251

Posted on 2005-04-06
12
Medium Priority
?
535 Views
Last Modified: 2011-08-18
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
0
Comment
Question by:lzha022
  • 7
  • 5
12 Comments
 
LVL 4

Expert Comment

by:abancroft
ID: 13767085
Is Transform referenced in the declaration of class Model? i.e. in the Model header file.
0
 

Author Comment

by:lzha022
ID: 13767186
Yes, in deader declared as Transform tran;
I think that is the reason of the warnings.
0
 
LVL 4

Expert Comment

by:abancroft
ID: 13767259
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lzha022
ID: 13767638
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.

0
 
LVL 4

Expert Comment

by:abancroft
ID: 13767942
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.
0
 

Author Comment

by:lzha022
ID: 13768088
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
0
 
LVL 4

Expert Comment

by:abancroft
ID: 13768106
Is the Transform class all inline? i.e. is all it's code in it's header file.
0
 

Author Comment

by:lzha022
ID: 13768107
...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.
0
 

Author Comment

by:lzha022
ID: 13768111
Is the Transform class all inline? No, it is a complete class
0
 
LVL 4

Accepted Solution

by:
abancroft earned 100 total points
ID: 13768118
Your best best is to export Transform from the DLL. If that really is not accepatable, you could write a small test app that uses Model, build it & run it.
0
 

Author Comment

by:lzha022
ID: 13768151
Thanks, I will try it
0
 

Author Comment

by:lzha022
ID: 13768447
Looks like it works
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month20 days, 8 hours left to enroll

867 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