我今天注意到我的一个标头文件仍在使用auto_ptr<>
模板。
我使用-std = c ++ 11来确保在C ++ 11和-pedantic和-Werror中进行编译以检测不推荐的使用情况。所以我想我在编译那个标题时应该有一个错误,因为auto_ptr被标记为已弃用,您怎么看?
该课程的一部分内容具有令人反感的定义:
class server
{
[...snip...]
private:
std::auto_ptr<snap_listen_thread> f_listen_runner;
std::auto_ptr<snap_thread> f_listen_thread;
[...snip...]
};
以下列出了所有命令行选项。我正在使用g ++版本4.8.2(Ubuntu 4.8.2-19ubuntu1),我们可以看到列表中有-pedantic和-Werror:
cd / home / snapwebsites / BUILD / snapwebsites / lib&amp;&amp; / usr / bin / c ++ -DCONTROLLED_VARS_DEBUG -DDEBUG -DQT_CORE_LIB -DQT_DEBUG -DQT_XMLPATTERNS_LIB -DQT_XML_LIB -D_DEBUG -Dsnapwebsites_EXPORTS -std = c ++ 11 -Werror -Wall -Wextra -pedantic -Wcast-align -Wcast-qual -Wctor-dtor-隐私-Wdisabled-optimization -Winit-self -Wlogical-op -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow = 4 -Wundef -Wno- unused -Wunused-variable -Wno-variadic-macros -Wno-parentheses -Wno-unknown-pragmas -Wwrite-strings -Wswitch -fdiagnostics-show-option -fPIC -Wunused-parameter -Wfloat-equal -Wold-style-cast - Wnoexcept -g -g -O0 -fPIC -I / home / snapwebsites / snapwebsites -I / home / snapwebsites / snapwebsites / lib -I / home / snapwebsites / BUILD / snapwebsites -I / home / snapwebsites / BUILD / snapwebsites / lib - I / home / snapwebsites / BUILD / dist / include -I / home / snapwebsites / BUILD / dist / include / advgetopt -I / home / snapwebsites / BUILD / dist / include / QtSerialization -isystem / usr / include / qt4 -isystem / USR /包含/ QT4 / QtXmlPatterns -isystem / usr / include / qt4 / QtXml -isystem / usr / include / qt4 / QtCore -isystem / usr / include / qt4 / QtDesigner -isystem / usr / include / qt4 / QtDeclarative -isystem / usr / include / qt4 / QtScriptTools -isystem / usr / include / qt4 / QtDBus -isystem / usr / include / qt4 / QtSql -isystem / usr / include / qt4 / QtOpenGL -isystem / usr / include / qt4 / QtNetwork -isystem / usr / include / qt4 / QtWebKit -isystem / usr / include / qt4 / QtHelp -isystem / usr / include / qt4 / QtUiTools -isystem / usr / include / qt4 / QtTest -isystem / usr / include / qt4 / QtScript -isystem / usr / include / qt4 / QtSvg -isystem / usr / include / qt4 / Qt3Support -isystem / usr / include / qt4 / QtGui -isystem / usr / share / qt4 / mkspecs / default -isystem / usr / include / proc -o CMakeFiles / snapwebsites.dir / snap_initialize_website。 cpp.o -c /home/snapwebsites/snapwebsites/lib/snap_initialize_website.cpp
g ++中是否存在一个错误,它偶尔会检测到这些已弃用的模板?
答案 0 :(得分:0)
正如我的一条评论所述,在其他人的帮助下,我发现-isystem
命令行选项是罪魁祸首。
g ++用标记所有内容,不要警告这个标志,当引用这些库中的任何内容以及它们包含的内容时都设置了标志...不幸的是很多库(有点Qt和特别是log4cplus)不编译而没有警告。