gcc warning" 'will be initialized after'

前端 未结 7 801
走了就别回头了
走了就别回头了 2020-12-22 16:38

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

7条回答
  •  时光取名叫无心
    2020-12-22 17:18

    The order of initialization doesn’t matter. All fields are initialized in the order of their definition in their class/struct. But if the order in initialization list is different gcc/g++ generate this warning. Only change the initialization order to avoid this warning. But you can't define field using in initialization before its construct. It will be a runtime error. So you change the order of definition. Be careful and keep attention!

提交回复
热议问题