问题描述
我正在将基于ATL的静态库转换为DLL,并且在使用ATL c> CString 类的任何导出类中都会收到以下警告(在atlstr.h中找到):
I am converting an ATL-based static library to a DLL and am getting the following warning on any exported classes that use the ATL CString class (found in atlstr.h):
我正确地声明了 Foo 通过 __ declspec(dllexport)导出的类。这是一个警告我可以放心忽视还是我做错了? DLL项目设置设置为与ATL动态链接,但这似乎没有任何区别。
I am correctly declaring the Foo class as exported via __declspec(dllexport). Is this a warning I can safely ignore or am I doing something wrong? The DLL project settings are set to dynamically link with ATL, but this doesn't seem to make any difference.
例如:
#ifdef DLLTEST_EXPORTS #define DLLTEST_API __declspec(dllexport) #else #define DLLTEST_API __declspec(dllimport) #endif // This class is exported from the DLLTest.dll class DLLTEST_API Foo { public: Foo(); CString str_; // WARNING C4251 HERE };
此DLL的所有客户端也将使用ATL。
All clients of this DLL will also be using ATL.
推荐答案
给出了我认为更好的答案,Doug Harrison(VC ++ MVP):
This thread gives what I consider a better answer, by Doug Harrison (VC++ MVP):
这篇关于警告C4251构建导出包含ATL :: CString成员的类的DLL时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!