CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Compiler warning C4275

    I'm building somebody else's source code and I'm constantly getting compiler warnings like this:-

    warning C4275: non-DLL interface class 'boost::noncopyable_::noncopyable' used as base class for DLL interface class
    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:-

    MSDN C4275

    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:-

    All your static data is accessed through functions that are exported from the DLL
    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)

    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

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured