March 21st, 2014, 05:03 AM
Compiler warning C4275
I'm building somebody else's source code and I'm constantly getting compiler warnings like this:-
To be fair, I don't seem to be getting any problems at run time but I was curious to find out what the warning was telling me, so I ended up here:-
warning C4275: non-DLL interface class 'boost::noncopyable_::noncopyable' used as base class for DLL interface class
I do understand the English but I'm not getting some of the concepts. For example, I can understand why (if the derived class was a template class) it shouldn't access static data (I'd assume that's almost always true for template classes anyway?) And I get this statement:-
Which again is good practice anyway. What I don't get is the implication that doing these things would have been fine if the base class had been declared with __declspec(dllexport)
All your static data is accessed through functions that are exported from the DLL
Whether or not the base class was exported, why should it make any difference to accessing static data
Last edited by John E; March 21st, 2014 at 05:05 AM.
"A problem well stated is a problem half solved.” - Charles F. Kettering
March 21st, 2014, 07:40 AM
Re: Compiler warning C4275
THis is a warning only, not an error.
You are exporting a class from a dll, but that class is derived from a base class which isn't being exported itself.
This isn't necessarily a problem, but it means that the users of your dll may not be able to directly call members of the base class.
that's why you get the issue about template classes
if the base class is a template class and it accesses a static a member function, then the code may end up being inlined, but the linker won't be able to resolve this because the user-code has no direct access to the members of the base class.
It doesn't have to be a base class btw, the same would be true for any member function of the base class which is defined inline in the header. (but this is typically Always true for templated classes).
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.