gcc 警告"'将在之后初始化' [英] gcc warning" 'will be initialized after'
本文介绍了gcc 警告"'将在之后初始化'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从无法修改的第 3 方代码中收到很多此类警告.有没有办法禁用此警告或至少在某些区域禁用它(例如 VC++ 中的#pragma push/pop)?
I am getting a lot of these warnings from 3rd party code that I cannot modify. Is there a way to disable this warning or at least disable it for certain areas (like #pragma push/pop in VC++)?
例子:
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_'
推荐答案
确保成员出现在初始化列表中的顺序与它们在类中出现的顺序相同
Make sure the members appear in the initializer list in the same order as they appear in the class
Class C {
int a;
int b;
C():b(1),a(2){} //warning, should be C():a(2),b(1)
}
或者你可以转-Wno-reorder
这篇关于gcc 警告"'将在之后初始化'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文