GCC编译器警告:扩展初始化程序列表仅在c ++ 0x中可用 [英] GCC Compiler Warning: extended initializer lists only available with c++0x
问题描述
StatsScreen :: StatsScreen(GameState :: State level)
: m_Level(level){
... //
}
我得到以下警告......
$ 扩展初始化程序列表仅适用于-std = c ++ 0x或-std = gnu ++ 0x
有关此警告的任何信息?
编辑:删除后警告消失的成员在构造函数中赋值(无法通过成员初始化完成),并将其设置为局部变量而不是类成员。我想你是用 {0}来初始化对象的, ...}
而不是(...)
:
StatsScreen ss {...}; //仅在C ++中有效0x
StatsScreen ss(...); //在C ++ 98中确定
要将代码编译为C ++ 0x代码,只需添加编译时出现以下标志:
g ++ test.cpp -std = c ++ 0x
Using this member initialization...
StatsScreen::StatsScreen( GameState::State level )
: m_Level( level ) {
...//
}
I get the following warning...
extended initializer lists only available with -std=c++0x or -std=gnu++0x
Any information regarding this warning?
Edit: Warning went away after I removed one of the member that was assigned to a value inside the constructor (couldn't be done through member initialization) and made it a local variable instead of a class member. Still want to know what that warnings means though.
I think you are initializing the object with {...}
instead of (...)
:
StatsScreen ss{...}; // only available in C++0x
StatsScreen ss(...); // OK in C++98
To compile your code as C++0x code, just add the following flag when compiling:
g++ test.cpp -std=c++0x
这篇关于GCC编译器警告:扩展初始化程序列表仅在c ++ 0x中可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!