From: Stephen Howe on 15 Dec 2009 15:02 Hi Using VS2005 Professional I have bog-standard Win32 DLL, and it has an export header file like so #ifdef MOD_EXPORTS #define MOD_API __declspec(dllexport) #else #define MOD_API __declspec(dllimport) #endif class MOD_API CObj1 { private: CObj2 m_Obj2; }; Now CObj2 resides in a proper library file (not an import library but a real library) Both the Win32 DLL and the proper library use the RTL in DLL form yet I am getting warning C4251: 'CObj1::m_Obj2 : class 'CObj2' needs to have dll-interface to be used by clients of class 'CObj1' How do I eliminate this warning correctly (I dont mean shut the compiler up with a pragma, but I do if the warning is spurious)? For that matter, how do I give CObj2 a DLL interface? Thanks Stephen Howe
From: Igor Tandetnik on 15 Dec 2009 15:26 Stephen Howe <sjhoweATdialDOTpipexDOTcom> wrote: > I have bog-standard Win32 DLL, and it has an export header file like > so > > #ifdef MOD_EXPORTS > #define MOD_API __declspec(dllexport) > #else > #define MOD_API __declspec(dllimport) > #endif > > class MOD_API CObj1 > { > > private: > CObj2 m_Obj2; > }; > > > Now CObj2 resides in a proper library file (not an import library but > a real library) > Both the Win32 DLL and the proper library use the RTL in DLL form yet > I am getting > > warning C4251: 'CObj1::m_Obj2 : class 'CObj2' needs to have > dll-interface to be used by clients of class 'CObj1' > > How do I eliminate this warning correctly (I dont mean shut the > compiler up with a pragma, but I do if the warning is spurious)? For > that matter, how do I give CObj2 a DLL interface? You give it a DLL interface the same way you gave it to CObj1: class MOD_API CObj2 {...}; The compiler probably could have realized that m_Obj2 is private and inaccessible to clients of CObj1, but it doesn't. It assumes that, if a class is exported to a DLL, all its members' types should also be exported. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
From: Stephen Howe on 16 Dec 2009 06:50 >> How do I eliminate this warning correctly (I dont mean shut the >> compiler up with a pragma, but I do if the warning is spurious)? For >> that matter, how do I give CObj2 a DLL interface? > >You give it a DLL interface the same way you gave it to CObj1: > >class MOD_API CObj2 {...}; > >The compiler probably could have realized that m_Obj2 is private and inaccessible to clients of CObj1, but it doesn't. It assumes that, if a class is exported to a DLL, all its members' types should also be exported. So that means the warning is spurious Igor? I hope MS updates the warning so it is issued under more restricted circumstances (i.e. when relevant) The class is internal to the main class. It is actually a wrapper around FILE * (so that it if the destructor is called and the file is still open, it is closed). Thanks Stephen Howe
From: Igor Tandetnik on 16 Dec 2009 08:07 Stephen Howe wrote: >>> How do I eliminate this warning correctly (I dont mean shut the >>> compiler up with a pragma, but I do if the warning is spurious)? For >>> that matter, how do I give CObj2 a DLL interface? >> >> You give it a DLL interface the same way you gave it to CObj1: >> >> class MOD_API CObj2 {...}; >> >> The compiler probably could have realized that m_Obj2 is private and inaccessible to clients of CObj1, but it doesn't. It >> assumes that, if a class is exported to a DLL, all its members' types should also be exported. > > So that means the warning is spurious Igor? If CObj2 is not accessible to external clients by any means, then yes it is. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
|
Pages: 1 Prev: std::vector error Next: Who Know How To set Windows password without old one -- VC Or C# |