我正在尝试使用 wxWidgets 3.0 库编译以下代码:
foo.h
#ifdef __GNUC__
#include <wx/version.h>
#if wxMAJOR_VERSION >= 3
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" //< I'm trying to disable warning
#endif // wxMAJOR_VERSION >= 3
#endif // __GNUC__
#ifdef HAVE_VARIADIC_MACROS
#undef HAVE_VARIADIC_MACROS //< this macro redefines in wx.h
#endif // HAVE_VARIADIC_MACROS
#include <wx/wx.h> //< deprecated constructor defined here
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
foo.cpp
#include "foo.h"
....
some_menu = new wxMenuItem( ... ); //< deprecated constructor
文件wx/menuitem.h 代码中定义的构造函数:
#if WXWIN_COMPATIBILITY_2_8 //< defined
// compatibility only, don't use in new code
wxDEPRECATED_CONSTRUCTOR(
wxMenuItem(wxMenu *parentMenu,
int id,
const wxString& text,
const wxString& help,
bool isCheckable,
wxMenu *subMenu = NULL)
);
#endif
使用 gcc 5.4.0、Ubuntu 16.04 x86_64 编译:
g++ -o foo.os -c -I/usr/lib/x86_64-linux-gnu/wx/include/gtk2-unicode-3.0 -I/usr/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -g3 -Wall -Werror
...
foo.cpp:83:109: error: 'wxMenuItem::wxMenuItem(...)' is deprecated [-Werror=deprecated-declarations]
我该如何解决?