我想在一個類中使用常量[默認啓用],它應該在C++ 11不錯,但我得到這樣的警告:標記如何關閉編譯器警告代碼塊中
warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
的問題是,我得到這麼多(超過10個)次每隔恆定我宣佈。這有效地填充構建消息,並使其他編譯器警告無法找到。 我想使它所以這不再是我構建的消息框出現。
我知道人們喜歡看相關代碼,所以在這裏它是:
class GameState: public State
{
public:
const Uint8 * keyStates;
Point gameMousePos;
int UIType;
std::vector<UI *> UIs;
Texture * lockingTex;
HitBox * inGame;
const int buttonDim = 100;
const int buttonOffY = 70;//distance from bottom
const int buttonOffX = 130;//distance from each other
const int buttonTextOffY = 140;//text distance from bottom
bool locking;
bool noPlaceBool;
float gameSpaceScale;
HitBox * gameSpace;
Texture * bkg;
float windowRotSpeed;
float inHandRotSpeed;
float windowMoveSpeed;
GameState();
void handle_events();
void logic();
void render();
void save();
void load_save();
}
可能的重複:http://stackoverflow.com/questions/3378560/how-to-disable-gcc-warnings-for-a-few-lines-of-code – JBentley
替代重複:http://stackoverflow.com/questions/1079997/disable-specific-warnings-in-gcc – JBentley
也許一個愚蠢的問題,但你*是*爲C++ 11編譯配置的,對吧?你有沒有考慮過使用靜態'constexpr'? – WhozCraig