From e252f8d84e9b9c69bc02c128be5141407e928117 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 23 Feb 2016 15:43:15 +0300 Subject: Fix compilation with gcc 4.4 or older. --- src/being/localplayer.cpp | 6 +++--- src/dyetool/client.cpp | 6 +++--- src/gui/sdlinput.cpp | 12 ++++++------ src/gui/widgets/dropdown.cpp | 6 +++--- src/gui/widgets/tabs/setup_colors.cpp | 6 +++--- src/gui/widgets/textbox.cpp | 6 +++--- src/gui/widgets/textfield.cpp | 12 ++++++------ src/gui/windows/charcreatedialog.cpp | 6 +++--- src/gui/windows/charselectdialog.cpp | 6 +++--- src/gui/windows/chatwindow.cpp | 6 +++--- src/gui/windows/killstats.cpp | 6 +++--- src/gui/windows/ministatuswindow.cpp | 6 +++--- src/gui/windows/quitdialog.cpp | 6 +++--- src/gui/windows/serverdialog.cpp | 6 +++--- src/gui/windows/statuswindow.cpp | 6 +++--- src/gui/windows/whoisonline.cpp | 6 +++--- src/localconsts.h | 9 ++++++++- src/net/download.cpp | 6 +++--- 18 files changed, 65 insertions(+), 58 deletions(-) diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 0afb36b42..6b883040c 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -1162,8 +1162,8 @@ void LocalPlayer::attributeChanged(const AttributesT id, const int oldVal, const int newVal) { - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (id) { case Attributes::EXP: @@ -1187,7 +1187,7 @@ void LocalPlayer::attributeChanged(const AttributesT id, default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") } void LocalPlayer::move(const int dX, const int dY) diff --git a/src/dyetool/client.cpp b/src/dyetool/client.cpp index a1b539c0f..727bfecc4 100644 --- a/src/dyetool/client.cpp +++ b/src/dyetool/client.cpp @@ -583,8 +583,8 @@ int Client::gameExec() BLOCK_END("Client::gameExec 7") BLOCK_START("Client::gameExec 8") - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (mState) { case State::GAME: @@ -636,7 +636,7 @@ int Client::gameExec() mState = State::FORCE_QUIT; break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") BLOCK_END("Client::gameExec 8") } PROFILER_END(); diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 42c61b5de..7b0d7dca9 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -333,8 +333,8 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event) int value = keysym.unicode; #endif - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (keysym.sym) { case SDLK_TAB: @@ -496,12 +496,12 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event) default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") if (!(CAST_U32(keysym.mod) & KMOD_NUM)) { - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (keysym.sym) { case SDLK_KP0: @@ -537,7 +537,7 @@ int SDLInput::convertKeyCharacter(const SDL_Event &event) default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") } return value; } diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 9648b97c0..c4c15a303 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -332,8 +332,8 @@ void DropDown::keyPressed(KeyEvent& event) return; const InputActionT actionId = event.getActionId(); - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (actionId) { case InputAction::GUI_SELECT: @@ -364,7 +364,7 @@ void DropDown::keyPressed(KeyEvent& event) default: return; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") event.consume(); } diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 8235aab2b..d2f51afe5 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -288,8 +288,8 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED) // probably need combite both switches and add all mssing color ids. - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (type) { case UserColorId::AIR_COLLISION_HIGHLIGHT: @@ -364,7 +364,7 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED) mGradDelaySlider->setScale(20, 100); break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") if (grad != GradientType::STATIC && grad != GradientType::PULSE) { // If nonstatic color, don't display the current, but the committed // color at the sliders diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index abb03a1ca..13cb07da9 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -257,8 +257,8 @@ void TextBox::keyPressed(KeyEvent& event) const Key &key = event.getKey(); const InputActionT action = event.getActionId(); - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (action) { case InputAction::GUI_LEFT: @@ -432,7 +432,7 @@ void TextBox::keyPressed(KeyEvent& event) break; } } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") adjustSize(); scrollToCaret(); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 34c088540..4060f8d1a 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -396,8 +396,8 @@ void TextField::keyPressed(KeyEvent &event) bool TextField::handleNormalKeys(const InputActionT action, bool &consumed) { - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (action) { case InputAction::GUI_LEFT: @@ -477,14 +477,14 @@ bool TextField::handleNormalKeys(const InputActionT action, bool &consumed) default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") return true; } void TextField::handleCtrlKeys(const InputActionT action, bool &consumed) { - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (action) { case InputAction::GUI_LEFT: @@ -575,7 +575,7 @@ void TextField::handleCtrlKeys(const InputActionT action, bool &consumed) default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") } void TextField::moveCaretBack() diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 6f88b8388..b172f788c 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -823,8 +823,8 @@ void CharCreateDialog::updatePlayer() void CharCreateDialog::keyPressed(KeyEvent &event) { const InputActionT actionId = event.getActionId(); - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (actionId) { case InputAction::GUI_CANCEL: @@ -836,7 +836,7 @@ void CharCreateDialog::keyPressed(KeyEvent &event) default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") } void CharCreateDialog::setButtonsPosition(const int w, const int h) diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 6ecee2257..95bb964d1 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -337,8 +337,8 @@ void CharSelectDialog::use(const int selected) void CharSelectDialog::keyPressed(KeyEvent &event) { const InputActionT actionId = event.getActionId(); - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (actionId) { case InputAction::GUI_CANCEL: @@ -428,7 +428,7 @@ void CharSelectDialog::keyPressed(KeyEvent &event) default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") } /** diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 7a4867441..b4b73ff23 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -979,8 +979,8 @@ void ChatWindow::attributeChanged(const AttributesT id, { if (!mShowBattleEvents) return; - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (id) { case Attributes::EXP: @@ -1003,7 +1003,7 @@ void ChatWindow::attributeChanged(const AttributesT id, default: break; }; - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") } void ChatWindow::addInputText(const std::string &text, const bool space) diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp index 22d977723..0269f9fcb 100644 --- a/src/gui/windows/killstats.cpp +++ b/src/gui/windows/killstats.cpp @@ -405,8 +405,8 @@ void KillStats::attributeChanged(const AttributesT id, const int oldVal, const int newVal) { - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (id) { case Attributes::EXP: @@ -438,5 +438,5 @@ void KillStats::attributeChanged(const AttributesT id, default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") } diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index 7168846a0..267401707 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -270,8 +270,8 @@ void MiniStatusWindow::attributeChanged(const AttributesT id, const int oldVal A_UNUSED, const int newVal A_UNUSED) { - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (id) { case Attributes::HP: @@ -296,7 +296,7 @@ void MiniStatusWindow::attributeChanged(const AttributesT id, default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") } void MiniStatusWindow::updateStatus() diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp index 4049d74fc..cda477346 100644 --- a/src/gui/windows/quitdialog.cpp +++ b/src/gui/windows/quitdialog.cpp @@ -205,8 +205,8 @@ void QuitDialog::keyPressed(KeyEvent &event) const InputActionT actionId = event.getActionId(); int dir = 0; - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (actionId) { case InputAction::GUI_SELECT: @@ -225,7 +225,7 @@ void QuitDialog::keyPressed(KeyEvent &event) default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") if (dir != 0) { diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index b326e2f91..158d5909e 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -310,8 +310,8 @@ void ServerDialog::action(const ActionEvent &event) void ServerDialog::keyPressed(KeyEvent &event) { - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (event.getActionId()) { case InputAction::GUI_CANCEL: @@ -356,7 +356,7 @@ void ServerDialog::keyPressed(KeyEvent &event) default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") if (!event.isConsumed()) mServersList->keyPressed(event); } diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index c2f54bfd1..979da2859 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -309,8 +309,8 @@ void StatusWindow::attributeChanged(const AttributesT id, const int oldVal A_UNUSED, const int newVal) { - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (id) { case Attributes::HP: @@ -370,7 +370,7 @@ void StatusWindow::attributeChanged(const AttributesT id, default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") } void StatusWindow::setPointsNeeded(const AttributesT id, diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index bde463d74..2698ef918 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -565,8 +565,8 @@ int WhoIsOnline::downloadThread(void *ptr) if ((res = curl_easy_perform(curl)) != 0) { wio->mDownloadStatus = UPDATE_ERROR; - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (res) { case CURLE_COULDNT_CONNECT: @@ -577,7 +577,7 @@ int WhoIsOnline::downloadThread(void *ptr) << url.c_str() << std::endl; break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") attempts++; curl_easy_cleanup(curl); curl_slist_free_all(pHeaders); diff --git a/src/localconsts.h b/src/localconsts.h index 09e0eae8b..82cbcbb25 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -156,7 +156,14 @@ #define const2 #define PRAGMA6(str) #endif // ADVGCC -#define PRAGMA(str) _Pragma(str) + +#ifdef __GNUC__ +#if GCC_VERSION > 40500 +#define PRAGMA45(str) _Pragma(str) +#else // GCC_VERSION > 40400 +#define PRAGMA45(str) +#endif // GCC_VERSION > 40400 +#endif // __GNUC__ #ifdef __GNUC__ #ifdef ENABLE_CILKPLUS diff --git a/src/net/download.cpp b/src/net/download.cpp index 196b9e19d..48e1d8ed4 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -351,8 +351,8 @@ int Download::downloadThread(void *ptr) if ((res = curl_easy_perform(d->mCurl)) != 0 && !d->mOptions.cancel) { - PRAGMA("GCC diagnostic push") - PRAGMA("GCC diagnostic ignored \"-Wswitch-enum\"") + PRAGMA45("GCC diagnostic push") + PRAGMA45("GCC diagnostic ignored \"-Wswitch-enum\"") switch (res) { case CURLE_ABORTED_BY_CALLBACK: @@ -362,7 +362,7 @@ int Download::downloadThread(void *ptr) default: break; } - PRAGMA("GCC diagnostic pop") + PRAGMA45("GCC diagnostic pop") if (res) { -- cgit v1.2.3-60-g2f50