我用VC建立了一个win32DLL的工程,但是我在我的类里面用了其他的非导出类就会有warning,就是弄不掉。 高手,帮帮忙吧。 5555  谢谢了。举个例子如下:
我的代码是:
// test.cpp : Defines the entry point for the DLL application.
//#include "stdafx.h"
#include "test.h"
#include <vector>
using namespace std;BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
 )
{
    switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
    }
    return TRUE;
}
class __declspec(dllexport) baby
{
public:
baby() {}
private:
vector<int> a;
};
然后会出现warning:
warning C4251: 'a' : class 'std::vector<int,class std::allocator<int> >' needs to have dll-interface to be used by clients of class 'baby'

解决方案 »

  1.   

    http://search.csdn.net/Expert/topic/1290/1290348.xml?temp=.1187555
      

  2.   

    http://support.microsoft.com/default.aspx?scid=KB;en-us;q168958
    HOWTO: Exporting STL Components Inside & Outside of a Class
    http://support.microsoft.com/default.aspx?scid=KB;en-us;q172396
    PRB: Access Violation When Accessing STL Object in DLL
      

  3.   

    #pragma warning (disable : 4251)
      

  4.   

    非常感谢,不过我还想问问我上面的那些代码应该改成什么样子才能 0(error)和 0(warning)呢?
      

  5.   

    我晕,没人回答了嘛? 我的分数都要全给  oyljerry(【勇敢的心】→ ㊣Winterize√㊣) 了啊。 有人知道嘛? 快啊。
      

  6.   

    基类或结构必须用 __declspec(dllexport) 关键字声明,派生类中的函数才能导出。
      

  7.   

    我知道要导出STL,但是我想问的是上面的代码要这么改才能 0 error, 0 warning  ??