VS2005 warning C4251 needs to have dll-interface
2008-12-22 13:07
453 查看
程序中消除warning有两种方法:消极一点不去理他,反正不是error:-);积极一点,则想办法去掉。去掉又用两种方法:一种使用#pragma warning(disable: xxxx),眼不见,心不烦;另外就是找出解决问题的办法了。
今天做dll库时,在struct中用到了stl:
class CLASS_TEST
{
...
private:
std::vector<MY_STRUCT> m_structs;
}
但是编译时,vs2005给出了warning C4251: 'CLASS_TEST::m_structs' : class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class ‘CLASS_TEST’的警告信息。费了很大的劲才解决掉,记录下来。
在头文件中,定义宏
#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif
现在,在变量m_structs前,添加:
template class MYDLL_API std::allocator<myStruct>;
template class MYDLL_API std::vector<myStruct, std::allocator<myStruct> >;
这样,即可以了。
今天做dll库时,在struct中用到了stl:
class CLASS_TEST
{
...
private:
std::vector<MY_STRUCT> m_structs;
}
但是编译时,vs2005给出了warning C4251: 'CLASS_TEST::m_structs' : class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class ‘CLASS_TEST’的警告信息。费了很大的劲才解决掉,记录下来。
在头文件中,定义宏
#ifdef MYDLL_EXPORTS
#define MYDLL_API __declspec(dllexport)
#else
#define MYDLL_API __declspec(dllimport)
#endif
现在,在变量m_structs前,添加:
template class MYDLL_API std::allocator<myStruct>;
template class MYDLL_API std::vector<myStruct, std::allocator<myStruct> >;
这样,即可以了。
相关文章推荐
- 如何解决VC中的警告warning C4251 needs to have dll-interface
- 去除Warning C4251 “class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class
- 如何解决VC中的警告warning C4251 needs to have dll-interface
- warning C4251 needs to have dll-interface解决办法
- warning C4251: 'm_ListInfo' : struct 'DuiLib::tagTListInfoUI' needs to have dll-interface to be used
- warning C4251: 'vectortemp::m_Vector' : class 'std::vector' needs to have dll-interface to be used by clients of class 'vectorte
- warning C4251 needs to have dll-interface解决办法
- warning C4251 needs to have dll-interface解决办法
- 'needs to have dll-interface' warning
- 【转】WARNING! File system needs to be upgraded. You have version null and I want version 7. Run the '${HBASE_HOME}/bin/hbase migrate' script. 的解决办法
- note : add COM interface To Shell Extension DLL
- File system needs to be upgraded. You have version null and I want version 7
- Extension commands need mscorwks.dll in order to have something to do.的一种情况
- The "Exec" task needs a command to execute,[小问题,大麻烦,vs2005的貌似BUG的设定]
- unity 错误 Texture atlas needs textures to have Readable flag set!
- AcroIEHelper.dll无法写入,Verify that you have access to that directory
- Error 1310 Error writing to file:C:\Windows\...*.dll. Verify that you have access to that directory
- Howto implement callback interface from unmanaged DLL to .net app?
- How to create .lib file when you only have .dll and .h files
- How to debug a vb dll for asp