LK_*_*K__ 214 g++ suppress-warnings
我从第三方代码中得到了很多这些警告,我无法修改.有没有办法禁用此警告或至少禁用某些区域(如VC++中的#pragma push/pop)?
例:
list.h:1122: warning: `list<LogOutput*, allocator<LogOutput*> >::node_alloc_' will be initialized after
list.h:1117: warning: `allocator<LogOutput*> list<LogOutput*, allocator<LogOutput*> >::alloc_'
Run Code Online (Sandbox Code Playgroud)
ura*_*ray 348
确保成员按照它们在类中显示的顺序出现在初始化列表中
Class C {
int a;
int b;
C():b(1),a(2){} //warning, should be C():a(2),b(1)
}
Run Code Online (Sandbox Code Playgroud)
或者你可以转 -Wno-reorder
小智 16
对于那些使用QT有此错误的人,请将其添加到.pro文件中
QMAKE_CXXFLAGS_WARN_ON += -Wno-reorder
Run Code Online (Sandbox Code Playgroud)
Class C {
int a;
int b;
C():b(1),a(2){} //warning, should be C():a(2),b(1)
}
Run Code Online (Sandbox Code Playgroud)
顺序很重要,因为如果 a 在 b 之前初始化,则 a 取决于 b。将会出现未定义的行为。
如果您看到来自库头文件的错误并且您正在使用 GCC,那么您可以通过使用-isystem代替包含头文件来禁用警告-I。
类似的功能存在于clang 中。
如果您使用 CMake,则可以指定SYSTEMfor include_directories.
| 归档时间: |
|
| 查看次数: |
120478 次 |
| 最近记录: |