gcc 警告 " 'will be initialized after' 質問する

gcc 警告

変更できないサードパーティのコードから、このような警告が多数表示されます。この警告を無効にする方法、または少なくとも特定の領域 (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_'

ベストアンサー1

初期化リスト内のメンバーがクラス内と同じ順序で表示されるようにしてください。

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

または-Wno-reorder

おすすめ記事