widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #01250
[Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
SirVer has proposed merging lp:~widelands-dev/widelands/cxx11 into lp:widelands.
Requested reviews:
Tino (tino79)
Widelands Developers (widelands-dev)
Related bugs:
Bug #1159432 in widelands: "Warnings at compile-time in GCC 4.8"
https://bugs.launchpad.net/widelands/+bug/1159432
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/cxx11/+merge/175455
This is a gentle introduction of c++11 into the codebase. I think it is a good time to do this before b18, but we will move slowly with the freaky c++11 features.
It works on Mac with clang and gcc, could Linux and Windows people check this please?
--
https://code.launchpad.net/~widelands-dev/widelands/cxx11/+merge/175455
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/cxx11 into lp:widelands.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-03-30 12:52:36 +0000
+++ CMakeLists.txt 2013-07-18 06:34:34 +0000
@@ -155,6 +155,7 @@
option (WL_STRICT "If strict compilation mode is requested (almost every warning is an error)" OFF)
+set (PARAMETER_COMPILERFLAG_CXXSTD "-std=c++11")
set (PARAMETER_COMPILERFLAG_OLDSTYLECAST_EXTENDED "-Wold-style-cast -isystem ${Boost_INCLUDE_DIR}")
set (PARAMETER_COMPILERFLAG_OLDSTYLECAST "-Wold-style-cast")
set (PARAMETER_COMPILERFLAG_GENERICWARNINGS "-Wall -Wextra")
@@ -162,6 +163,13 @@
set (PARAMETER_COMPILERFLAG_GCCWARNINGS "-Wlogical-op -Wsync-nand -Wtrampolines")
set (PARAMETER_COMPILERFLAG_STRICT "-Werror -Wno-error=old-style-cast -Wno-error=deprecated-declarations -fdiagnostics-show-option")
include(CheckCXXCompilerFlag) #this include should be safe
+
+CHECK_CXX_COMPILER_FLAG(${PARAMETER_COMPILERFLAG_CXXSTD} Compiler_std_supported)
+IF (Compiler_std_supported)
+ set (WL_COMPILERFLAG_CXXSTD " ${PARAMETER_COMPILERFLAG_CXXSTD}") #the space is on purpose!
+ENDIF (Compiler_std_supported)
+
+
CHECK_CXX_COMPILER_FLAG(${PARAMETER_COMPILERFLAG_OLDSTYLECAST_EXTENDED} Compiler_old-style-cast_supported)
IF (Compiler_old-style-cast_supported)
EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
@@ -217,6 +225,8 @@
message("Warning: could not add additional GCC-specific warning options: ${PARAMETER_COMPILERFLAG_GCCWARNINGS}. Most likely you are using a different compiler, like Clang/LLVM.")
ENDIF (Compiler_gcc_warnings_supported)
+CHECK_CXX_COMPILER_FLAG(${PARAMETER_COMPILERFLAG_GCCWARNINGS} Compiler_gcc_warnings_supported)
+
IF (WL_STRICT)
CHECK_CXX_COMPILER_FLAG(${PARAMETER_COMPILERFLAG_STRICT} Compiler_strict_mode_supported)
IF (Compiler_strict_mode_supported)
@@ -226,7 +236,7 @@
ENDIF (WL_STRICT)
# CMAKE only defines "-g", but we need -DDEBUG also, and we need -DNOPARACHUTE (for SDL) in Debug
-set (CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG -DNOPARACHUTE${WL_COMPILERFLAG_OLDSTYLECAST}${WL_COMPILERFLAG_GENERICWARNINGS}${WL_COMPILERFLAG_EXTRAWARNINGS}${WL_COMPILERFLAG_GCCWARNINGS}${WL_COMPILERFLAG_STRICT}" CACHE STRING "Set by widelands CMakeLists.txt" FORCE)
+set (CMAKE_CXX_FLAGS_DEBUG "${WL_COMPILERFLAG_CXXSTD} -g -DDEBUG -DNOPARACHUTE${WL_COMPILERFLAG_OLDSTYLECAST}${WL_COMPILERFLAG_GENERICWARNINGS}${WL_COMPILERFLAG_EXTRAWARNINGS}${WL_COMPILERFLAG_GCCWARNINGS}${WL_COMPILERFLAG_STRICT}" CACHE STRING "Set by widelands CMakeLists.txt" FORCE)
set (WL_COMPILERFLAG_OPTIMIZATIONS "-O3")
@@ -245,7 +255,7 @@
ENDIF (WLBUILD_COMPILERVERSION_REP STREQUAL "4.5.1" OR WLBUILD_COMPILERVERSION_REP STREQUAL "4.5.2")
ENDIF (CMAKE_COMPILER_IS_GNUCXX)
-set (CMAKE_CXX_FLAGS_RELEASE "${WL_COMPILERFLAG_OPTIMIZATIONS} -DNDEBUG${WL_COMPILERFLAG_OLDSTYLECAST}${WL_COMPILERFLAG_GENERICWARNINGS}${WL_COMPILERFLAG_EXTRAWARNINGS}${WL_COMPILERFLAG_GCCWARNINGS}${WL_COMPILERFLAG_STRICT}" CACHE STRING "Set by widelands CMakeLists.txt" FORCE)
+set (CMAKE_CXX_FLAGS_RELEASE "${WL_COMPILERFLAG_CXXSTD} ${WL_COMPILERFLAG_OPTIMIZATIONS} -DNDEBUG${WL_COMPILERFLAG_OLDSTYLECAST}${WL_COMPILERFLAG_GENERICWARNINGS}${WL_COMPILERFLAG_EXTRAWARNINGS}${WL_COMPILERFLAG_GCCWARNINGS}${WL_COMPILERFLAG_STRICT}" CACHE STRING "Set by widelands CMakeLists.txt" FORCE)
#If building with MSVC, then check for 3rdparty libs
if (DEFINED MSVC)
=== removed file 'src/compile_assert.h'
--- src/compile_assert.h 2013-02-10 18:47:18 +0000
+++ src/compile_assert.h 1970-01-01 00:00:00 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2006 by the Widelands Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef compile_assert
-// gnu needs to append a unique number to the assert, otherwise it complains
-// about this shadowing the last assert. This is not too easy, so we use the
-// line number - collisions are not that probable anymore.
-// The concatenation magic is from: http://stackoverflow.com/a/1597129/200945
-#define TOKENPASTE(x, y) x ## y
-#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
-#define compile_assert(x) typedef bool TOKENPASTE2(COMPILE_ASSERT_, __LINE__)[(x) ? 1 : -1]
-#endif
=== modified file 'src/economy/fleet.cc'
--- src/economy/fleet.cc 2013-06-20 19:59:07 +0000
+++ src/economy/fleet.cc 2013-07-18 06:34:34 +0000
@@ -669,7 +669,7 @@
Map_Object::log_general_info(egbase);
molog
- ("%"PRIuS" ships and %"PRIuS" ports\n", m_ships.size(), m_ports.size());
+ ("%" PRIuS " ships and %" PRIuS " ports\n", m_ships.size(), m_ports.size());
}
#define FLEET_SAVEGAME_VERSION 4
=== modified file 'src/economy/portdock.cc'
--- src/economy/portdock.cc 2013-07-14 10:38:26 +0000
+++ src/economy/portdock.cc 2013-07-18 06:34:34 +0000
@@ -519,7 +519,7 @@
Coords pos(m_warehouse->get_position());
molog
- ("PortDock for warehouse %u (at %i,%i) in fleet %u, need_ship: %s, waiting: %"PRIuS"\n",
+ ("PortDock for warehouse %u (at %i,%i) in fleet %u, need_ship: %s, waiting: %" PRIuS "\n",
m_warehouse ? m_warehouse->serial() : 0, pos.x, pos.y,
m_fleet ? m_fleet->serial() : 0,
m_need_ship ? "true" : "false",
=== modified file 'src/graphic/animation_gfx.cc'
--- src/graphic/animation_gfx.cc 2013-02-10 17:39:24 +0000
+++ src/graphic/animation_gfx.cc 2013-07-18 06:34:34 +0000
@@ -146,7 +146,7 @@
if (m_pcmasks.size() and m_pcmasks.size() < m_frames.size())
throw wexception
- ("animation has %"PRIuS" frames but playercolor mask has only %"PRIuS" frames",
+ ("animation has %" PRIuS " frames but playercolor mask has only %" PRIuS " frames",
m_frames.size(), m_pcmasks.size());
}
=== modified file 'src/graphic/render/gamerenderer_gl.cc'
--- src/graphic/render/gamerenderer_gl.cc 2013-07-13 14:32:49 +0000
+++ src/graphic/render/gamerenderer_gl.cc 2013-07-18 06:34:34 +0000
@@ -233,7 +233,7 @@
void GameRendererGL::prepare_terrain_base()
{
- compile_assert(sizeof(basevertex) == 32);
+ static_assert(sizeof(basevertex) == 32, "assert(sizeof(basevertex) == 32) failed.");
uint32_t reqsize = m_patch_size.w * m_patch_size.h;
if (reqsize > 0x10000)
@@ -408,7 +408,7 @@
*/
void GameRendererGL::prepare_terrain_dither()
{
- compile_assert(sizeof(dithervertex) == 32);
+ static_assert(sizeof(dithervertex) == 32, "assert(sizeof(dithervertex) == 32) failed.");
if (m_terrain_edge_freq.size() < 16)
m_terrain_edge_freq.resize(16);
=== modified file 'src/graphic/text/rt_render.cc'
--- src/graphic/text/rt_render.cc 2013-04-22 20:15:00 +0000
+++ src/graphic/text/rt_render.cc 2013-07-18 06:34:34 +0000
@@ -158,7 +158,7 @@
// Image is inserted, the width will become wider after it. This is a
// constraint change.
struct ConstraintChange {
- uint16_t at_y;
+ int at_y;
int32_t delta_w;
int32_t delta_offset_x;
=== modified file 'src/io/bitinbuffer.h'
--- src/io/bitinbuffer.h 2012-09-21 21:36:07 +0000
+++ src/io/bitinbuffer.h 2013-07-18 06:34:34 +0000
@@ -22,15 +22,13 @@
#include "fileread.h"
-#include "compile_assert.h"
-
/// Wrapper around FileRead for reading groups of Size bits from a file, where
/// Size can be a factor of 8. Call get to read Size bits from the buffer.
/// Attempts to read more bits than have been written to the BitOutBuffer when
/// the file was created will not fail unless it causes another byte to be read
/// from the file.
template<uint8_t const Size> struct BitInBuffer {
- compile_assert(Size == 1 or Size == 2 or Size == 4);
+ static_assert(Size == 1 or Size == 2 or Size == 4, "assert(Size == 1 or Size == 2 or Size == 4) failed.");
BitInBuffer() : buffer(0), mask(0x00) {}
void Open(FileSystem & fs, char const * const filename) {
fr.Open(fs, filename);
=== modified file 'src/io/bitoutbuffer.h'
--- src/io/bitoutbuffer.h 2012-02-15 21:25:34 +0000
+++ src/io/bitoutbuffer.h 2013-07-18 06:34:34 +0000
@@ -22,13 +22,11 @@
#include "filewrite.h"
-#include "compile_assert.h"
-
/// Wrapper around FileWrite for writing bits to a file. Call put to write a
/// bit to the buffer. Call Write to write the buffer to file. Unassigned bits
/// in the last byte will be 0.
template<uint8_t const Size> struct BitOutBuffer {
- compile_assert(Size == 1 or Size == 2 or Size == 4);
+ static_assert(Size == 1 or Size == 2 or Size == 4, "assert(Size == 1 or Size == 2 or Size == 4) failed.");
BitOutBuffer() : buffer(0x00), mask(0xff) {}
void put(uint8_t const item) {
assert(item < (1 << Size));
=== modified file 'src/io/filesystem/disk_filesystem.cc'
--- src/io/filesystem/disk_filesystem.cc 2013-02-25 17:03:31 +0000
+++ src/io/filesystem/disk_filesystem.cc 2013-07-18 06:34:34 +0000
@@ -44,9 +44,6 @@
#include <sys/statvfs.h>
#include <sys/types.h>
#include <fcntl.h>
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE // for O_NOATIME
-#endif
#endif
#include "io/streamread.h"
@@ -402,7 +399,7 @@
if (size and (result != 1)) {
assert(false);
throw wexception
- ("RealFSImpl::Load: read failed for %s (%s) with size %"PRIuS"",
+ ("RealFSImpl::Load: read failed for %s (%s) with size %" PRIuS "",
fname.c_str(), fullname.c_str(), size);
}
static_cast<int8_t *>(data)[size] = 0;
=== modified file 'src/log.h'
--- src/log.h 2013-04-20 20:20:34 +0000
+++ src/log.h 2013-07-18 06:34:34 +0000
@@ -38,7 +38,7 @@
// Use these macros after a % in a printf format string
// to get correct 32/64 bit behavior, like this:
// size_t size = records.size();
-// printf("%"PRIuS"\n", size);
+// printf("%" PRIuS "\n", size);
#define PRIdS __PRIS_PREFIX "d"
#define PRIxS __PRIS_PREFIX "x"
=== modified file 'src/logic/constructionsite.cc'
--- src/logic/constructionsite.cc 2013-07-15 05:18:12 +0000
+++ src/logic/constructionsite.cc 2013-07-18 06:34:34 +0000
@@ -345,7 +345,7 @@
// Draw the partially finished building
- compile_assert(0 <= CONSTRUCTIONSITE_STEP_TIME);
+ static_assert(0 <= CONSTRUCTIONSITE_STEP_TIME, "assert(0 <= CONSTRUCTIONSITE_STEP_TIME) failed.");
m_info.totaltime = CONSTRUCTIONSITE_STEP_TIME * m_work_steps;
m_info.completedtime = CONSTRUCTIONSITE_STEP_TIME * m_work_completed;
=== modified file 'src/logic/dismantlesite.cc'
--- src/logic/dismantlesite.cc 2013-07-15 05:18:12 +0000
+++ src/logic/dismantlesite.cc 2013-07-18 06:34:34 +0000
@@ -247,7 +247,7 @@
dst.drawanim(pos, m_anim, tanim, get_owner());
// Draw the partially dismantled building
- compile_assert(0 <= DISMANTLESITE_STEP_TIME);
+ static_assert(0 <= DISMANTLESITE_STEP_TIME, "assert(0 <= DISMANTLESITE_STEP_TIME) failed.");
uint32_t total_time = DISMANTLESITE_STEP_TIME * m_work_steps;
uint32_t completed_time = DISMANTLESITE_STEP_TIME * m_work_completed;
=== modified file 'src/logic/field.h'
--- src/logic/field.h 2013-07-14 10:43:19 +0000
+++ src/logic/field.h 2013-07-18 06:34:34 +0000
@@ -21,7 +21,6 @@
#define FIELD_H
#include "widelands_geometry.h"
-#include "compile_assert.h"
#include "constants.h"
#include "nodecaps.h"
#include "world.h"
@@ -79,11 +78,11 @@
typedef uint8_t Resource_Amount;
struct Terrains {Terrain_Index d : 4, r : 4;};
- compile_assert(sizeof(Terrains) == 1);
+ static_assert(sizeof(Terrains) == 1, "assert(sizeof(Terrains) == 1) failed.");
struct Resources {Resource_Index d : 4, r : 4;};
- compile_assert(sizeof(Resources) == 1);
+ static_assert(sizeof(Resources) == 1, "assert(sizeof(Resources) == 1) failed.");
struct Resource_Amounts {Resource_Amount d : 4, r : 4;};
- compile_assert(sizeof(Resource_Amounts) == 1);
+ static_assert(sizeof(Resource_Amounts) == 1, "assert(sizeof(Resource_Amounts) == 1) failed.");
private:
/**
@@ -110,7 +109,7 @@
Border_Bitmask - 1;
static const Owner_Info_and_Selections_Type Owner_Info_Bitmask =
Player_Number_Bitmask + Border_Bitmask;
- compile_assert(MAX_PLAYERS <= Player_Number_Bitmask);
+ static_assert(MAX_PLAYERS <= Player_Number_Bitmask, "Bitmask is too big.");
// Data Members
/** linked list, \sa Bob::m_linknext*/
@@ -236,7 +235,7 @@
#pragma pack(pop)
// Check that Field is tightly packed.
-compile_assert(sizeof(Field) <= sizeof(void *) * 2 + 10);
+static_assert(sizeof(Field) <= sizeof(void *) * 2 + 10, "Field is not tightly packed.");
}
#endif
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2013-07-15 05:18:12 +0000
+++ src/logic/game.cc 2013-07-18 06:34:34 +0000
@@ -220,7 +220,7 @@
set_map(new Map);
- std::auto_ptr<Map_Loader> maploader(map().get_correct_loader(mapname));
+ std::unique_ptr<Map_Loader> maploader(map().get_correct_loader(mapname));
if (not maploader.get())
throw wexception("could not load \"%s\"", mapname);
UI::ProgressWindow loaderUI;
@@ -286,7 +286,7 @@
assert(!get_map());
set_map(new Map);
- std::auto_ptr<Map_Loader> maploader
+ std::unique_ptr<Map_Loader> maploader
(map().get_correct_loader(settings.mapfilename.c_str()));
maploader->preload_map(settings.scenario);
std::string const background = map().get_background();
=== modified file 'src/logic/ship.cc'
--- src/logic/ship.cc 2013-07-13 13:54:06 +0000
+++ src/logic/ship.cc 2013-07-18 06:34:34 +0000
@@ -570,7 +570,7 @@
*/
void Ship::set_destination(Game & game, PortDock & pd)
{
- molog("set_destination to %u (currently %"PRIuS" items)\n", pd.serial(), m_items.size());
+ molog("set_destination to %u (currently %" PRIuS " items)\n", pd.serial(), m_items.size());
m_destination = &pd;
send_signal(game, "wakeup");
}
@@ -677,7 +677,7 @@
Bob::log_general_info(egbase);
molog
- ("Fleet: %u, destination: %u, lastdock: %u, carrying: %"PRIuS"\n",
+ ("Fleet: %u, destination: %u, lastdock: %u, carrying: %" PRIuS "\n",
m_fleet? m_fleet->serial() : 0,
m_destination.serial(), m_lastdock.serial(),
m_items.size());
=== modified file 'src/logic/trainingsite.cc'
--- src/logic/trainingsite.cc 2013-07-16 15:26:46 +0000
+++ src/logic/trainingsite.cc 2013-07-18 06:34:34 +0000
@@ -37,6 +37,8 @@
namespace Widelands {
+const uint32_t TrainingSite::training_state_multiplier;
+
TrainingSite_Descr::TrainingSite_Descr
(char const * const _name, char const * const _descname,
const std::string & directory, Profile & prof, Section & global_s,
=== modified file 'src/logic/warehouse.cc'
--- src/logic/warehouse.cc 2013-06-02 19:00:22 +0000
+++ src/logic/warehouse.cc 2013-07-18 06:34:34 +0000
@@ -496,7 +496,7 @@
return;
}
- molog("Found %"PRIuS" fields for the dock\n", dock.size());
+ molog("Found %" PRIuS " fields for the dock\n", dock.size());
m_portdock = new PortDock;
m_portdock->set_owner(get_owner());
=== modified file 'src/logic/widelands_geometry.h'
--- src/logic/widelands_geometry.h 2013-04-25 07:27:14 +0000
+++ src/logic/widelands_geometry.h 2013-07-18 06:34:34 +0000
@@ -20,8 +20,6 @@
#ifndef WIDELANDS_GEOMETRY_H
#define WIDELANDS_GEOMETRY_H
-#include "compile_assert.h"
-
#include <cmath>
#include <stdint.h>
@@ -82,7 +80,7 @@
union {struct {X_Coordinate x; Y_Coordinate y;}; uint32_t all;};
};
-compile_assert(sizeof(Coords) == 4);
+static_assert(sizeof(Coords) == 4, "assert(sizeof(Coords) == 4) failed.");
template <typename _Coords_type = Coords, typename _Radius_type = uint16_t>
struct Area : public _Coords_type
=== modified file 'src/map_io/widelands_map_buildingdata_data_packet.cc'
--- src/map_io/widelands_map_buildingdata_data_packet.cc 2013-07-08 03:59:31 +0000
+++ src/map_io/widelands_map_buildingdata_data_packet.cc 2013-07-18 06:34:34 +0000
@@ -1068,8 +1068,8 @@
statistics_string_length)
log
("WARNING: productionsite statistics string can be at "
- "most %"PRIuS" characters but a loaded building has the "
- "string \"%s\" of length %"PRIuS"\n",
+ "most %" PRIuS " characters but a loaded building has the "
+ "string \"%s\" of length %" PRIuS "\n",
sizeof(productionsite.m_statistics_buffer) - 1,
statistics_string, statistics_string_length);
}
@@ -1086,8 +1086,8 @@
result_string_length)
log
("WARNING: productionsite result string can be at "
- "most %"PRIuS" characters but a loaded building has the "
- "string \"%s\" of length %"PRIuS"\n",
+ "most %" PRIuS " characters but a loaded building has the "
+ "string \"%s\" of length %" PRIuS "\n",
sizeof(productionsite.m_result_buffer) - 1,
result_string, result_string_length);
}
=== modified file 'src/map_io/widelands_map_exploration_data_packet.cc'
--- src/map_io/widelands_map_exploration_data_packet.cc 2013-02-10 19:36:24 +0000
+++ src/map_io/widelands_map_exploration_data_packet.cc 2013-07-18 06:34:34 +0000
@@ -54,7 +54,7 @@
}
}
- compile_assert(MAX_PLAYERS < 32);
+ static_assert(MAX_PLAYERS < 32, "assert(MAX_PLAYERS < 32) failed.");
Map & map = egbase.map();
Player_Number const nr_players = map.get_nrplayers();
Map_Index const max_index = map.max_index();
@@ -105,7 +105,7 @@
fw.Unsigned16(CURRENT_PACKET_VERSION);
- compile_assert(MAX_PLAYERS < 32);
+ static_assert(MAX_PLAYERS < 32, "assert(MAX_PLAYERS < 32) failed.");
Map & map = egbase.map();
Player_Number const nr_players = map.get_nrplayers();
Map_Index const max_index = map.max_index();
=== modified file 'src/minizip/unzip.cc'
--- src/minizip/unzip.cc 2013-07-18 05:40:10 +0000
+++ src/minizip/unzip.cc 2013-07-18 06:34:34 +0000
@@ -69,14 +69,6 @@
#endif
/* compile with -Dlocal if your debugger can't find static symbols */
-
-#ifndef CASESENSITIVITYDEFAULT_NO
-# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
-# define CASESENSITIVITYDEFAULT_NO
-# endif
-#endif
-
-
#ifndef UNZ_BUFSIZE
#define UNZ_BUFSIZE (16384)
#endif
=== modified file 'src/scripting/pluto.cc'
--- src/scripting/pluto.cc 2013-07-18 05:40:10 +0000
+++ src/scripting/pluto.cc 2013-07-18 06:34:34 +0000
@@ -598,7 +598,7 @@
/* Serialize code */
{
- compile_assert(sizeof(Instruction) == 4);
+ static_assert(sizeof(Instruction) == 4, "assert(sizeof(Instruction) == 4) failed.");
pi->fw->Signed32(p->sizecode);
for (int32_t i = 0; i < p->sizecode; i++)
pi->fw->Unsigned32(p->code[i]);
=== removed file 'src/type_check.h'
--- src/type_check.h 2012-02-15 21:25:34 +0000
+++ src/type_check.h 1970-01-01 00:00:00 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2009 by the Widelands Development Team
- *
- * This program is free software; you can redistribute it and/or
- * modify 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TYPE_CHECK
-#define TYPE_CHECK
-
-template <int BYTES>
-struct only1byte {
- enum {result = false};
-};
-
-template <>
-struct only1byte<1> {
- enum {result = true};
-};
-
-#endif
=== modified file 'src/ui_basic/checkbox.cc'
--- src/ui_basic/checkbox.cc 2013-02-10 19:36:24 +0000
+++ src/ui_basic/checkbox.cc 2013-07-18 06:34:34 +0000
@@ -22,8 +22,6 @@
#include "graphic/graphic.h"
#include "graphic/rendertarget.h"
-#include "compile_assert.h"
-
namespace UI {
/**
* Stateboxes start out enabled and unchecked.
@@ -117,8 +115,8 @@
dst.draw_rect
(Rect(Point(0, 0), get_w(), get_h()), RGBColor(100, 100, 80));
} else {
- compile_assert(0 <= STATEBOX_WIDTH);
- compile_assert(0 <= STATEBOX_HEIGHT);
+ static_assert(0 <= STATEBOX_WIDTH, "assert(0 <= STATEBOX_WIDTH) failed.");
+ static_assert(0 <= STATEBOX_HEIGHT, "assert(0 <= STATEBOX_HEIGHT) failed.");
dst.blitrect
(Point(0, 0),
m_pic_graphics,
=== modified file 'src/ui_basic/listselect.h'
--- src/ui_basic/listselect.h 2013-06-15 14:08:10 +0000
+++ src/ui_basic/listselect.h 2013-07-18 06:34:34 +0000
@@ -27,7 +27,6 @@
#include <boost/signal.hpp>
#include "align.h"
-#include "compile_assert.h"
#include "panel.h"
#include "rgbcolor.h"
=== modified file 'src/ui_basic/table.h'
--- src/ui_basic/table.h 2013-02-10 19:36:24 +0000
+++ src/ui_basic/table.h 2013-07-18 06:34:34 +0000
@@ -28,7 +28,6 @@
#include <boost/signal.hpp>
#include "align.h"
-#include "compile_assert.h"
#include "rgbcolor.h"
#include "panel.h"
@@ -402,7 +401,7 @@
}
};
-compile_assert(sizeof(void *) == sizeof(uintptr_t));
+static_assert(sizeof(void *) == sizeof(uintptr_t), "assert(sizeof(void *) == sizeof(uintptr_t)) failed.");
template <> class Table<uintptr_t> : public Table<void *> {
public:
typedef Table<void *> Base;
=== modified file 'src/ui_basic/tabpanel.cc'
--- src/ui_basic/tabpanel.cc 2013-02-10 19:36:24 +0000
+++ src/ui_basic/tabpanel.cc 2013-07-18 06:34:34 +0000
@@ -23,8 +23,6 @@
#include "graphic/rendertarget.h"
-#include "compile_assert.h"
-
namespace UI {
#define TP_BUTTON_WIDTH 34
#define TP_BUTTON_HEIGHT 34
@@ -205,8 +203,8 @@
uint32_t x;
// draw the background
- compile_assert(2 < TP_BUTTON_WIDTH);
- compile_assert(4 < TP_BUTTON_HEIGHT);
+ static_assert(2 < TP_BUTTON_WIDTH, "assert(2 < TP_BUTTON_WIDTH) failed.");
+ static_assert(4 < TP_BUTTON_HEIGHT, "assert(4 < TP_BUTTON_HEIGHT) failed.");
if (m_pic_background) {
dst.tile
=== modified file 'src/ui_basic/window.cc'
--- src/ui_basic/window.cc 2013-02-10 19:36:24 +0000
+++ src/ui_basic/window.cc 2013-07-18 06:34:34 +0000
@@ -28,8 +28,6 @@
#include "text_layout.h"
#include "wlapplication.h"
-#include "compile_assert.h"
-
#include <SDL_keysym.h>
using namespace std;
@@ -299,7 +297,7 @@
Rect(Point(0, 0), pos, TP_B_PIXMAP_THICKNESS));
// top bar
- compile_assert(0 <= HZ_B_CORNER_PIXMAP_LEN);
+ static_assert(0 <= HZ_B_CORNER_PIXMAP_LEN, "assert(0 <= HZ_B_CORNER_PIXMAP_LEN) failed.");
for (; pos < hz_bar_end_minus_middle; pos += HZ_B_MIDDLE_PIXMAP_LEN)
dst.blitrect
(Point(pos, 0),
@@ -336,7 +334,7 @@
{ // Left border
- compile_assert(0 <= VT_B_PIXMAP_THICKNESS);
+ static_assert(0 <= VT_B_PIXMAP_THICKNESS, "assert(0 <= VT_B_PIXMAP_THICKNESS) failed.");
dst.blitrect // left top thingy
(Point(0, TP_B_PIXMAP_THICKNESS),
m_pic_lborder,
@@ -345,7 +343,7 @@
int32_t pos = TP_B_PIXMAP_THICKNESS + VT_B_THINGY_PIXMAP_LEN;
// left bar
- compile_assert(0 <= VT_B_THINGY_PIXMAP_LEN);
+ static_assert(0 <= VT_B_THINGY_PIXMAP_LEN, "assert(0 <= VT_B_THINGY_PIXMAP_LEN) failed.");
for (; pos < vt_bar_end_minus_middle; pos += VT_B_MIDDLE_PIXMAP_LEN)
dst.blitrect
(Point(0, pos),
@@ -377,7 +375,7 @@
int32_t pos = TP_B_PIXMAP_THICKNESS + VT_B_THINGY_PIXMAP_LEN;
// right bar
- compile_assert(0 <= VT_B_THINGY_PIXMAP_LEN);
+ static_assert(0 <= VT_B_THINGY_PIXMAP_LEN, "assert(0 <= VT_B_THINGY_PIXMAP_LEN) failed.");
for (; pos < vt_bar_end_minus_middle; pos += VT_B_MIDDLE_PIXMAP_LEN)
dst.blitrect
(Point(right_border_x, pos),
=== modified file 'src/vector.h'
--- src/vector.h 2012-07-13 20:46:30 +0000
+++ src/vector.h 2013-07-18 06:34:34 +0000
@@ -20,8 +20,6 @@
#ifndef VECTOR_H
#define VECTOR_H
-#include "compile_assert.h"
-
#include <cmath>
// hm, floats...
=== modified file 'src/wlapplication.cc'
--- src/wlapplication.cc 2013-07-16 14:05:48 +0000
+++ src/wlapplication.cc 2013-07-18 06:34:34 +0000
@@ -1660,7 +1660,8 @@
{
// This is the code returned by UI::Panel::run() when the panel is dying.
// Make sure that the program exits when the window manager says so.
- compile_assert(Fullscreen_Menu_SinglePlayer::Back == UI::Panel::dying_code);
+ static_assert
+ (Fullscreen_Menu_SinglePlayer::Back == UI::Panel::dying_code, "Panel should be dying.");
for (;;) {
int32_t code;
@@ -1775,7 +1776,8 @@
{
// This is the code returned by UI::Panel::run() when the panel is dying.
// Make sure that the program exits when the window manager says so.
- compile_assert(Fullscreen_Menu_Editor::Back == UI::Panel::dying_code);
+ static_assert
+ (Fullscreen_Menu_Editor::Back == UI::Panel::dying_code, "Editor should be dying.");
for (;;) {
int32_t code;
=== modified file 'src/wui/encyclopedia_window.cc'
--- src/wui/encyclopedia_window.cc 2013-02-10 19:36:24 +0000
+++ src/wui/encyclopedia_window.cc 2013-07-18 06:34:34 +0000
@@ -36,7 +36,6 @@
#include "ui_basic/table.h"
#include "upcast.h"
-#include "type_check.h"
#include <algorithm>
#include <set>
@@ -203,8 +202,7 @@
// Make sure to detect if someone changes the type so that it
// needs more than 3 decimal digits to represent.
- compile_assert
- (only1byte<sizeof(j.current->second)>::result);
+ static_assert(sizeof(j.current->second) == 1, "Number is too big for 3 char string.");
char amount_string[4]; // Space for 3 digits + terminator.
sprintf(amount_string, "%u", j.current->second);
Follow ups
-
[Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: noreply, 2013-07-21
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: SirVer, 2013-07-21
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: Tino, 2013-07-20
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: Hans Joachim Desserud, 2013-07-20
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: SirVer, 2013-07-20
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: SirVer, 2013-07-20
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: Tino, 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: SirVer, 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: Jens Beyer (Qcumber-some), 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: SirVer, 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: SirVer, 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: Jens Beyer (Qcumber-some), 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: Jens Beyer (Qcumber-some), 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: SirVer, 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: Jens Beyer (Qcumber-some), 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: Jens Beyer (Qcumber-some), 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: SirVer, 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: Hans Joachim Desserud, 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: Tino, 2013-07-19
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: cghislai, 2013-07-18
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: SirVer, 2013-07-18
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: Hans Joachim Desserud, 2013-07-18
-
Re: [Merge] lp:~widelands-dev/widelands/cxx11 into lp:widelands
From: SirVer, 2013-07-18