小编典典

gcc 警告" '将在之后初始化'

all

我从无法修改的第 3 方代码中收到很多警告。有没有办法禁用此警告或至少在某些区域禁用它(例如 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_'

阅读 90

收藏
2022-05-18

共1个答案

小编典典

确保成员出现在初始化列表中的顺序与它们在类中出现的顺序相同

Class C {
   int a;
   int b;
   C():b(1),a(2){} //warning, should be C():a(2),b(1)
}

或者你可以转-Wno-reorder

2022-05-18