Skip to content

Commit

Permalink
Made WARNING build option usable again
Browse files Browse the repository at this point in the history
* disabled compiler warning that currently make the build fail
* made warnings specific to the supertux2 target
* split of .c code into separate target, as gcc doesn't like C++ warning flags for C files
* fixed a few -Weffc++ issues in the code
  • Loading branch information
Grumbel committed Aug 10, 2014
1 parent fb7ec3e commit 2b4d375
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 29 deletions.
24 changes: 15 additions & 9 deletions CMakeLists.txt
Expand Up @@ -6,12 +6,12 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Expand Down Expand Up @@ -255,9 +255,13 @@ IF(CMAKE_COMPILER_IS_GNUCC)
REMOVE_DEFINITIONS(-Werror)
ENDIF(WERROR)
IF(WARNINGS)
ADD_DEFINITIONS(-fdiagnostics-show-option -pedantic -Wno-long-long -Wcast-align -Wdisabled-optimization -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wredundant-decls -Wstack-protector -Wconversion -Wundef -Wsign-conversion -Wshadow -Winline -Wunsafe-loop-optimizations -Wfloat-equal -Wswitch-default -Wswitch-enum -Wcast-qual -Wsign-promo -Woverloaded-virtual -Wmissing-format-attribute -Wstrict-overflow=5 -Wformat=2-Weffc++ -Wabi -Wctor-dtor-privacy -Wstrict-null-sentinel -Wno-unused-parameter)
# -ansi fails in MinGW
# still left: -Wold-style-cast -Wpadded
# temporarily disabled:
# -Wsign-conversion -Wfloat-equal -Wconversion -Wundef -Wshadow -Wswitch-default
# -Wswitch-enum -Wsign-promo -Wcast-qual -Woverloaded-virtual -Wmissing-format-attribute
# -Wold-style-cast -Wpadded
# fails on MinGW:
# -ansi
SET(SUPERTUX2_EXTRA_WARNING_FLAGS "-fdiagnostics-show-option -pedantic -Wno-long-long -Wcast-align -Wdisabled-optimization -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wredundant-decls -Wstack-protector -Winline -Wunsafe-loop-optimizations -Wstrict-overflow=5 -Wformat=2 -Weffc++ -Wabi -Wctor-dtor-privacy -Wstrict-null-sentinel -Wno-unused-parameter")
ENDIF(WARNINGS)
ENDIF(CMAKE_COMPILER_IS_GNUCC)

Expand Down Expand Up @@ -307,7 +311,7 @@ IF(GENERATE_MESSAGESPOT)
ENDFOREACH(SUPERTUX_LEVEL_DIR)

ADD_CUSTOM_TARGET(
supertux2-messages ALL
supertux2-messages ALL
DEPENDS ${MESSAGES_POT_FILES}
)

Expand Down Expand Up @@ -350,13 +354,15 @@ SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR})

## Add target for supertux binary

ADD_EXECUTABLE(supertux2 ${CMAKE_BINARY_DIR}/version.h ${SUPERTUX_SOURCES_C} ${SUPERTUX_SOURCES_CXX} ${TINYGETTEXT_SOURCES_CXX})
ADD_LIBRARY(supertux2_c OBJECT ${SUPERTUX_SOURCES_C})
ADD_EXECUTABLE(supertux2 ${CMAKE_BINARY_DIR}/version.h ${SUPERTUX_SOURCES_CXX} ${TINYGETTEXT_SOURCES_CXX} $<TARGET_OBJECTS:supertux2_c>)
ADD_DEPENDENCIES(supertux2 gitversion)
SET_TARGET_PROPERTIES(supertux2 PROPERTIES COMPILE_FLAGS "${SUPERTUX2_EXTRA_WARNING_FLAGS}")

## Link supertux binary with squirrel and other libraries

TARGET_INCLUDE_DIRECTORIES(supertux2 PUBLIC ${SDL2_INCLUDE_DIRS})
TARGET_INCLUDE_DIRECTORIES(supertux2 PUBLIC ${SDL2IMAGE_INCLUDE_DIRS})
TARGET_INCLUDE_DIRECTORIES(supertux2 SYSTEM PUBLIC ${SDL2_INCLUDE_DIRS})
TARGET_INCLUDE_DIRECTORIES(supertux2 SYSTEM PUBLIC ${SDL2IMAGE_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(supertux2 ${SDL2_LIBRARIES})
TARGET_LINK_LIBRARIES(supertux2 ${SDL2IMAGE_LIBRARIES})

Expand Down
3 changes: 2 additions & 1 deletion src/badguy/goldbomb.cpp
Expand Up @@ -31,7 +31,8 @@ GoldBomb::GoldBomb(const Reader& reader) :
WalkingBadguy(reader, "images/creatures/gold_bomb/gold_bomb.sprite", "left", "right"),
tstate(STATE_NORMAL),
grabbed(false),
grabber(NULL)
grabber(NULL),
ticking()
{
walk_speed = 80;
max_drop_height = 16;
Expand Down
4 changes: 3 additions & 1 deletion src/badguy/haywire.cpp
Expand Up @@ -34,7 +34,9 @@ Haywire::Haywire(const Reader& reader) :
is_exploding(false),
time_until_explosion(0.0f),
is_stunned(false),
time_stunned(0.0f)
time_stunned(0.0f),
ticking(),
grunting()
{
walk_speed = 80;
max_drop_height = 16;
Expand Down
2 changes: 1 addition & 1 deletion src/badguy/haywire.hpp
Expand Up @@ -44,7 +44,7 @@ class Haywire : public WalkingBadguy
bool is_stunned;
float time_stunned;

std::unique_ptr<SoundSource> ticking;
std::unique_ptr<SoundSource> ticking;
std::unique_ptr<SoundSource> grunting;
};

Expand Down
2 changes: 1 addition & 1 deletion src/badguy/livefire.cpp
Expand Up @@ -26,13 +26,13 @@
LiveFire::LiveFire(const Reader& reader) :
WalkingBadguy(reader, "images/creatures/livefire/livefire.sprite", "left", "right"),
lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-medium.sprite")),
death_sound("sounds/fall.wav"),
state(STATE_WALKING)
{
walk_speed = 80;
max_drop_height = 20;
lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
lightsprite->set_color(Color(1.0f, 0.9f, 0.8f));
death_sound = "sounds/fall.wav";
}

void
Expand Down
1 change: 1 addition & 0 deletions src/gui/menu.cpp
Expand Up @@ -327,6 +327,7 @@ Menu::process_input()
case MN_BACK:
MenuManager::instance().pop_menu();
break;

default:
break;
}
Expand Down
4 changes: 4 additions & 0 deletions src/object/bonus_block.cpp
Expand Up @@ -45,6 +45,8 @@ BonusBlock::BonusBlock(const Vector& pos, int data) :
contents(),
object(0),
hit_counter(1),
sprite_name(),
script(),
lightsprite()
{
bbox.set_pos(pos);
Expand Down Expand Up @@ -85,6 +87,8 @@ BonusBlock::BonusBlock(const Reader& lisp) :
contents(),
object(0),
hit_counter(1),
sprite_name(),
script(),
lightsprite()
{
Vector pos;
Expand Down
1 change: 1 addition & 0 deletions src/object/player.cpp
Expand Up @@ -117,6 +117,7 @@ Player::Player(PlayerStatus* _player_status, const std::string& name) :
duck(),
dead(),
dying(),
winning(),
backflipping(),
backflip_direction(),
peekingX(),
Expand Down
21 changes: 9 additions & 12 deletions src/supertux/game_session.cpp
Expand Up @@ -46,14 +46,14 @@

GameSession::GameSession(const std::string& levelfile_, PlayerStatus* player_status, Statistics* statistics) :
level(),
statistics_backdrop(),
statistics_backdrop(Surface::create("images/engine/menu/score-backdrop.png")),
scripts(),
currentsector(0),
currentsector(nullptr),
levelnb(),
pause_menu_frame(),
end_sequence(0),
game_pause(),
speed_before_pause(),
game_pause(false),
speed_before_pause(g_screen_manager->get_speed()),
levelfile(levelfile_),
reset_sector(),
reset_pos(),
Expand All @@ -67,15 +67,12 @@ GameSession::GameSession(const std::string& levelfile_, PlayerStatus* player_sta
demo_controller(0),
play_time(0),
edit_mode(false),
levelintro_shown(false)
levelintro_shown(false),
coins_at_start(),
bonus_at_start(),
max_fire_bullets_at_start(),
max_ice_bullets_at_start()
{
currentsector = NULL;

game_pause = false;
speed_before_pause = g_screen_manager->get_speed();

statistics_backdrop = Surface::create("images/engine/menu/score-backdrop.png");

if (restart_level() != 0)
throw std::runtime_error ("Initializing the level failed.");
}
Expand Down
3 changes: 2 additions & 1 deletion src/supertux/title_screen.cpp
Expand Up @@ -43,7 +43,8 @@
TitleScreen::TitleScreen(PlayerStatus* player_status) :
frame(),
controller(),
titlesession()
titlesession(),
copyright_text()
{
controller.reset(new CodeController());
titlesession.reset(new GameSession("levels/misc/menu.stl", player_status));
Expand Down
1 change: 1 addition & 0 deletions src/supertux/world.hpp
Expand Up @@ -59,6 +59,7 @@ class World
std::string worldname;
struct Level
{
Level() : fullpath(), name() {}
std::string fullpath;
std::string name;
};
Expand Down
3 changes: 2 additions & 1 deletion src/trigger/secretarea_trigger.cpp
Expand Up @@ -32,7 +32,8 @@ SecretAreaTrigger::SecretAreaTrigger(const Reader& reader) :
message_timer(),
message_displayed(),
message(),
fade_tilemap()
fade_tilemap(),
script()
{
reader.get("x", bbox.p1.x);
reader.get("y", bbox.p1.y);
Expand Down
2 changes: 2 additions & 0 deletions src/video/gl/gl_renderer.cpp
Expand Up @@ -37,6 +37,8 @@

GLRenderer::GLRenderer() :
window(),
glcontext(),
viewport(),
desktop_size(0, 0),
fullscreen_active(false),
last_texture(static_cast<GLuint> (-1))
Expand Down
4 changes: 4 additions & 0 deletions src/video/gl/gl_renderer.hpp
Expand Up @@ -132,6 +132,10 @@ class GLRenderer : public Renderer
Vector to_logical(int physical_x, int physical_y);
void set_gamma(float gamma);
SDL_Window* get_window() const { return window; }

private:
GLRenderer(const GLRenderer&) = delete;
GLRenderer& operator=(const GLRenderer&) = delete;
};

#endif
Expand Down
1 change: 1 addition & 0 deletions src/video/sdl/sdl_lightmap.cpp
Expand Up @@ -24,6 +24,7 @@

SDLLightmap::SDLLightmap() :
renderer(static_cast<SDLRenderer*>(Renderer::instance())->get_sdl_renderer()),
texture(),
width(),
height(),
LIGHTMAP_DIV()
Expand Down
4 changes: 3 additions & 1 deletion src/video/sdl/sdl_texture.cpp
Expand Up @@ -29,7 +29,9 @@
#include <SDL.h>

SDLTexture::SDLTexture(SDL_Surface* image) :
texture()
texture(),
width(),
height()
{
texture = SDL_CreateTextureFromSurface(static_cast<SDLRenderer*>(Renderer::instance())->get_sdl_renderer(),
image);
Expand Down
4 changes: 3 additions & 1 deletion src/worldmap/worldmap.cpp
Expand Up @@ -104,7 +104,9 @@ WorldMap::WorldMap(const std::string& filename, PlayerStatus* player_status, con
force_spawnpoint(force_spawnpoint),
in_level(false),
pan_pos(),
panning(false)
panning(false),
last_position(),
last_target_time()
{
tux = new Tux(this);
add_object(tux);
Expand Down

0 comments on commit 2b4d375

Please sign in to comment.