MySQL 的编译器警告++带有发布配置

发布于 2024-08-09 15:42:47 字数 1582 浏览 4 评论 0原文

由于某种原因,在使用发布配置构建时,我收到一些有关“非 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的他你的她 2024-08-16 15:42:47

对我来说显而易见的事情似乎是
我没有使用 dll 版本
CRT,但是因为我是
(“多线程 DLL (/MD)”
发布)这不是问题,所以
一定在其他地方...

1>c:\sql\mysql 5.0\mysql++-3.0.9\lib\qparms.h(49) :警告 C4275:非 dll 接口  

使用了“std::_Container_base_aux”类
作为 dll 接口类的基础
'std::_Container_base_aux_alloc_real<_Alloc>'

在处理跨 DLL 边界发送 STL 的代码时,我们可以安全地忽略此警告以及 C4251。该警告让您知道,如果另一个 dll 是使用其他 STL 版本(它无法立即弄清楚)构建的,则该类的导入/导出版本之间的占用空间将会有所不同。

我知道您使用的是 VS 2008,但是 MSDN 似乎暗示 2005 年您的具体情况可以安全地忽略:

C4275在Microsoft中可以被忽略
Visual C++ 2005(如果您正在推导)
来自标准 C++ 中的类型
库,编译调试版本
(/MTd) 以及编译器错误所在
消息引用_Container_base。

请注意对“调试版本”和 _Container_base 的引用

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...

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>'

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:

C4275 can be ignored in Microsoft
Visual C++ 2005 if you are deriving
from a type in the Standard C++
Library, compiling a debug release
(/MTd) and where the compiler error
message refers to _Container_base.

Notice the reference to "debug release" and _Container_base

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文