在一个项目中,我使用(有点旧的版本)vtk,它在gcc上生成一个不推荐使用的警告:
In file included from <path STL>/backward/strstream:51:0,
from <path VTK>/vtkIOStream.h:112,
from <path VTK>/vtkSystemIncludes.h:40,
from <path VTK>/vtkIndent.h:24,
from <path VTK>/vtkObjectBase.h:43,
from <path VTK>/vtkSmartPointerBase.h:26,
from <path VTK>/vtkSmartPointer.h:23,
from <some file in my project>
<path STL>/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
我要压制那个警告。到目前为止,我所尝试的是沿着罪魁祸首行使用pragma指令:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wno-deprecated"
#include <vtkSmartPointer.h>
#pragma GCC diagnostic pop
在回答中建议
How to suppress several warnings but not all of them coming from libraries?
但这不起作用,因为命令无法识别我的选项:
warning: unknown option after â#pragma GCC diagnosticâ kind [-Wpragmas]
#pragma GCC diagnostic ignored "-Wno-deprecated"
我想在这里具体说明我禁用的警告类型。不过,一个给我一个不太具体的选择的答案也会受到欢迎。我试过用它“墙”,但也不管用(承认但不压制)。
使用-wno deprecated编译整个项目会取消警告,这是我的回退选项,但不是我喜欢使用的选项。
我的重点是它在Linux和GCC下工作。我没有管理权限,不能在此更改vtk版本或gcc版本(4.8.5)。