MySQL 的编译器警告++带有发布配置
由于某种原因,在使用发布配置构建时,我收到一些有关“非 dll 接口类”的警告,但没有调试。
我已经将发布和调试配置以及我的配置与 MySQL++ 示例配置进行了比较,但是我看不到哪个设置导致了这些警告。
1>c:\sql\mysql 5.0\mysql++-3.0.9\lib\qparms.h(49) : warning C4275: non dll-interface class 'std::_Container_base_aux' used as base for dll-interface class 'std::_Container_base_aux_alloc_real<_Alloc>'
1> with
1> [
1> _Alloc=std::allocator<mysqlpp::SQLTypeAdapter>
1> ]
1> C:\apps\Microsoft Visual Studio 9.0\VC\include\xutility(377) : see declaration of 'std::_Container_base_aux'
1>c:\sql\mysql 5.0\mysql++-3.0.9\lib\result.h(212) : warning C4275...
警告中的代码片段:
class MYSQLPP_EXPORT SQLQueryParms : public std::vector<SQLTypeAdapter>
{
...
对我来说显而易见的事情似乎是我没有使用 CRT 的 dll 版本,但是因为我是(“多线程 DLL (/MD)”用于发布),所以这不可能是问题,所以必须在其他地方...
MYSQLPP_EXPORT 被定义为“__declspec(dllexport)”
编译器命令行,为了便于阅读,我缩短了一些路径,但是所有标志等都是相同的。
/O2 /Oi /GL /I "C:\SQL\MySQL 5.0\\include\\" /I "C:\SQL\MySQL 5.0\mysql++-3.0.9\\lib\\" /D "NDEBUG" /D "_WIN32" /D "_MBCS" /FD /EHsc /MD /Gy /Yu"precompiled.h" /Fp"C:\...\server.pch" /Fo"C:\..." /Fd"C:\...\vc90.pdb" /W3 /nologo /c /Zi /TP /errorReport:prompt
以及 MySQL++ 示例。
/Od /I "C:\SQL\MySQL 5.0\\include" /I "..\lib" /D "_CONSOLE" /D "UNICODE" /D "_UNICODE" /FD /EHsc /MD /Fo"C:\SQL\MySQL 5.0\mysql++-3.0.9\vc2008\Release\simple1\\" /Fd"C:\SQL\MySQL 5.0\mysql++-3.0.9\vc2008\Release\simple1.pdb" /W3 /nologo /c /TP /errorReport:prompt
For some reason I get some warnings about "non dll-interface class" when building with a release configuration, but not debug.
I've compared the release and debug configurations, and my ones with the MySQL++ example ones, however I cant see which setting is causing these warnings.
1>c:\sql\mysql 5.0\mysql++-3.0.9\lib\qparms.h(49) : warning C4275: non dll-interface class 'std::_Container_base_aux' used as base for dll-interface class 'std::_Container_base_aux_alloc_real<_Alloc>'
1> with
1> [
1> _Alloc=std::allocator<mysqlpp::SQLTypeAdapter>
1> ]
1> C:\apps\Microsoft Visual Studio 9.0\VC\include\xutility(377) : see declaration of 'std::_Container_base_aux'
1>c:\sql\mysql 5.0\mysql++-3.0.9\lib\result.h(212) : warning C4275...
Code snippet from the warning:
class MYSQLPP_EXPORT SQLQueryParms : public std::vector<SQLTypeAdapter>
{
...
The obvious thing to me seems to be that I'm not using a dll version of the CRT, however since I am ("Multi-threaded DLL (/MD)" for release) this cant be the problem, so must be somewhere else...
MYSQLPP_EXPORT is defined as "__declspec(dllexport)"
Compiler command line, I made some of the paths shorter for readability, however all the flags etc are the same.
/O2 /Oi /GL /I "C:\SQL\MySQL 5.0\\include\\" /I "C:\SQL\MySQL 5.0\mysql++-3.0.9\\lib\\" /D "NDEBUG" /D "_WIN32" /D "_MBCS" /FD /EHsc /MD /Gy /Yu"precompiled.h" /Fp"C:\...\server.pch" /Fo"C:\..." /Fd"C:\...\vc90.pdb" /W3 /nologo /c /Zi /TP /errorReport:prompt
And for a MySQL++ example.
/Od /I "C:\SQL\MySQL 5.0\\include" /I "..\lib" /D "_CONSOLE" /D "UNICODE" /D "_UNICODE" /FD /EHsc /MD /Fo"C:\SQL\MySQL 5.0\mysql++-3.0.9\vc2008\Release\simple1\\" /Fd"C:\SQL\MySQL 5.0\mysql++-3.0.9\vc2008\Release\simple1.pdb" /W3 /nologo /c /TP /errorReport:prompt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在处理跨 DLL 边界发送 STL 的代码时,我们可以安全地忽略此警告以及 C4251。该警告让您知道,如果另一个 dll 是使用其他 STL 版本(它无法立即弄清楚)构建的,则该类的导入/导出版本之间的占用空间将会有所不同。
我知道您使用的是 VS 2008,但是 MSDN 似乎暗示 2005 年您的具体情况可以安全地忽略:
请注意对“调试版本”和 _Container_base 的引用
This is a warning we ignore safely along with C4251 when dealing with code that sends STL across DLL boundaries. The warning is letting you know that if the other dll was built with some other STL version (which it can't figure out off hand) than the footprint of the class is going to differ between the imported/exported versions of the class.
I know you are using VS 2008, but MSDN seems to hint that for 2005 your exact situation can be safely ignored:
Notice the reference to "debug release" and _Container_base