Commit 1a04ce45 authored by Florian Oetke's avatar Florian Oetke
Browse files

tweaked compiler warnings

parent 53c3ca43
......@@ -190,7 +190,7 @@ if(GLM_INSTALL_ENABLE)
endif()
add_library(glm INTERFACE)
target_include_directories(glm INTERFACE
target_include_directories(glm SYSTEM INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
install(TARGETS glm EXPORT glmTargets)
......
......@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(gsl)
add_library(gsl INTERFACE)
target_include_directories(gsl INTERFACE
target_include_directories(gsl SYSTEM INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gsl/include>
$<INSTALL_INTERFACE:include>)
install(TARGETS gsl EXPORT gslTargets)
......
......@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(moodycamel LANGUAGES CXX)
add_library(moodycamel INTERFACE)
target_include_directories(moodycamel INTERFACE
target_include_directories(moodycamel SYSTEM INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
......
......@@ -167,7 +167,7 @@ if(PHYSFS_BUILD_STATIC)
set(PHYSFS_LIB_TARGET physfs-static)
set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs-static")
target_include_directories(physfs-static INTERFACE
target_include_directories(physfs-static SYSTEM INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>)
endif()
......@@ -185,7 +185,7 @@ if(PHYSFS_BUILD_SHARED)
set(PHYSFS_LIB_TARGET physfs)
set(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs")
target_include_directories(physfs INTERFACE
target_include_directories(physfs SYSTEM INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>)
endif()
......
......@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(robin-map)
add_library(robin-map INTERFACE)
target_include_directories(robin-map INTERFACE
target_include_directories(robin-map SYSTEM INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/robin-map>
$<INSTALL_INTERFACE:include>)
install(TARGETS robin-map EXPORT robin-mapTargets)
......
......@@ -193,7 +193,7 @@ namespace format {
_stream.put('"');
_stream.write(v, len);
_stream.write(v, static_cast<std::streamsize>(len));
_stream.put('"');
......@@ -217,11 +217,11 @@ namespace format {
}
inline void Json_writer::write(uint8_t v) {
_write((uint16_t) v);
_write(static_cast<uint16_t>(v));
}
inline void Json_writer::write(int8_t v) {
_write((int16_t) v);
_write(static_cast<int16_t>(v));
}
inline void Json_writer::write(uint16_t v) {
......
......@@ -28,16 +28,11 @@ namespace sf2 {
namespace details {
constexpr auto calc_hash(const char* data, std::size_t len)noexcept -> std::size_t {
return len==0 ? std::size_t(0) :
(len==1 ? std::size_t(0) : calc_hash(data+1, len-1)*101u) + std::size_t(data[0]);
/*
// requires N3652 (Relaxing constraints on constexpr-functions), that is not supported by gcc < 5.0 (mingw & ndk)
std::size_t h = 0;
for(std::size_t i=0; i<len; ++i)
h = h*101 + data[i];
return h;
*/
}
}
......@@ -175,13 +170,13 @@ namespace sf2 {
template<typename T>
auto get_enum_info() -> decltype(sf2_enum_info_factory((T*)nullptr)) {
return sf2_enum_info_factory((T*)nullptr);
auto get_enum_info() -> decltype(sf2_enum_info_factory(static_cast<T*>(nullptr))) {
return sf2_enum_info_factory(static_cast<T*>(nullptr));
}
template<typename T>
auto get_struct_info() -> decltype(sf2_struct_info_factory((T*)nullptr)) {
return sf2_struct_info_factory((T*)nullptr);
auto get_struct_info() -> decltype(sf2_struct_info_factory(static_cast<T*>(nullptr))) {
return sf2_struct_info_factory(static_cast<T*>(nullptr));
}
......@@ -191,12 +186,12 @@ namespace sf2 {
typedef char one;
typedef long two;
template <typename C> static one test( std::remove_reference_t<decltype(sf2_struct_info_factory((C*)nullptr))>* ) ;
template <typename C> static one test( std::remove_reference_t<decltype(sf2_struct_info_factory(static_cast<C*>(nullptr)))>* ) ;
template <typename C> static two test(...);
public:
enum { value = sizeof(test<T>(0)) == sizeof(char) };
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) };
};
template<class T>
......@@ -205,12 +200,12 @@ namespace sf2 {
typedef char one;
typedef long two;
template <typename C> static one test( std::remove_reference_t<decltype(sf2_enum_info_factory((C*)nullptr))>* ) ;
template <typename C> static one test( std::remove_reference_t<decltype(sf2_enum_info_factory(static_cast<C*>(nullptr)))>* ) ;
template <typename C> static two test(...);
public:
enum { value = sizeof(test<T>(0)) == sizeof(char) };
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) };
};
template<class T>
......
......@@ -47,7 +47,7 @@ namespace sf2 {
public:
enum { value = sizeof(test<T>(0)) == sizeof(char) };
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) };
};
template<class Reader, class T>
struct has_load {
......@@ -60,7 +60,7 @@ namespace sf2 {
public:
enum { value = sizeof(test<T>(0)) == sizeof(char) };
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) };
};
template<class T>
struct has_post_load {
......@@ -73,7 +73,7 @@ namespace sf2 {
public:
enum { value = sizeof(test<T>(0)) == sizeof(char) };
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) };
};
template<class T>
void call_post_load(T&, typename std::enable_if_t<!has_post_load<T>::value>* = nullptr) {
......@@ -94,7 +94,7 @@ namespace sf2 {
public:
enum { value = sizeof(test<T>(0, 0)) == sizeof(char) };
enum { value = sizeof(test<T>(nullptr, nullptr)) == sizeof(char) };
};
template<class T>
......@@ -108,7 +108,7 @@ namespace sf2 {
public:
enum { value = sizeof(test<T>(0)) == sizeof(char) };
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) };
};
template<class T>
......@@ -122,7 +122,7 @@ namespace sf2 {
public:
enum { value = sizeof(test<T>(0)) == sizeof(char) };
enum { value = sizeof(test<T>(nullptr)) == sizeof(char) };
};
template<class T>
......
......@@ -14,8 +14,17 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(MIRRAGE_DEFAULT_COMPILER_ARGS -Wextra -Wall -pedantic -Wunsafe-loop-optimizations -Wzero-as-null-pointer-constant -Wlogical-op -Werror -Wno-unused-parameter -Wno-unused-private-field -Wno-missing-braces)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(MIRRAGE_DEFAULT_COMPILER_ARGS -Wextra -Wall -pedantic -Wextra-semi
-Wzero-as-null-pointer-constant -Wold-style-cast -Werror
-Wno-unused-parameter -Wno-unused-private-field -Wno-missing-braces)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(MIRRAGE_DEFAULT_COMPILER_ARGS -Wextra -Wall -pedantic -Wunsafe-loop-optimizations
-Wzero-as-null-pointer-constant -Wlogical-op -Werror -Wno-unused-parameter
-Wno-unused-private-field -Wno-missing-braces
-Wno-error=unsafe-loop-optimizations)
elseif(MSVC)
set(MIRRAGE_DEFAULT_COMPILER_ARGS /Za)
endif()
......
......@@ -24,8 +24,8 @@ VkResult vkCreateDebugReportCallbackEXT(VkInstance
const VkDebugReportCallbackCreateInfoEXT* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkDebugReportCallbackEXT* pCallback) {
auto func = (PFN_vkCreateDebugReportCallbackEXT) vkGetInstanceProcAddr(instance,
"vkCreateDebugReportCallbackEXT");
auto func = reinterpret_cast<PFN_vkCreateDebugReportCallbackEXT>(
vkGetInstanceProcAddr(instance, "vkCreateDebugReportCallbackEXT"));
if(func != nullptr) {
return func(instance, pCreateInfo, pAllocator, pCallback);
} else {
......@@ -36,8 +36,8 @@ VkResult vkCreateDebugReportCallbackEXT(VkInstance
void vkDestroyDebugReportCallbackEXT(VkInstance instance,
VkDebugReportCallbackEXT callback,
const VkAllocationCallbacks* pAllocator) {
auto func = (PFN_vkDestroyDebugReportCallbackEXT) vkGetInstanceProcAddr(
instance, "vkDestroyDebugReportCallbackEXT");
auto func = reinterpret_cast<PFN_vkDestroyDebugReportCallbackEXT>(
vkGetInstanceProcAddr(instance, "vkDestroyDebugReportCallbackEXT"));
if(func != nullptr) {
func(instance, callback, pAllocator);
}
......
......@@ -146,7 +146,7 @@ namespace mirrage::graphic {
case Shader_stage::geometry: return vk::ShaderStageFlagBits::eGeometry;
case Shader_stage::fragment: return vk::ShaderStageFlagBits::eFragment;
}
MIRRAGE_FAIL("Unecpected Shader_stage " << ((int) s.stage));
MIRRAGE_FAIL("Unecpected Shader_stage " << static_cast<int>(s.stage));
}();
s.constants_info = vk::SpecializationInfo{gsl::narrow<std::uint32_t>(s.constants.size()),
......
......@@ -41,12 +41,8 @@ namespace mirrage::graphic {
}
} // namespace
Window::Window(std::string name,
std::string title,
int display,
int width,
int height,
Fullscreen fullscreen)
Window::Window(
std::string name, std::string title, int display, int width, int height, Fullscreen fullscreen)
: _name(name)
, _title(title)
, _display(display)
......@@ -94,9 +90,8 @@ namespace mirrage::graphic {
void Window::_update_fps_timer(double present_started) {
auto delta_time = static_cast<float>(util::current_time_sec() - _frame_start_time);
float smooth_factor = 0.1f;
_delta_time_smoothed =
(1.0f - smooth_factor) * _delta_time_smoothed + smooth_factor * delta_time;
float smooth_factor = 0.1f;
_delta_time_smoothed = (1.0f - smooth_factor) * _delta_time_smoothed + smooth_factor * delta_time;
auto cpu_delta_time = static_cast<float>(present_started - _frame_start_time);
_cpu_delta_time_smoothed =
......@@ -106,8 +101,7 @@ namespace mirrage::graphic {
if(_time_since_last_FPS_output >= 1.0f) {
_time_since_last_FPS_output = 0.0f;
std::ostringstream osstr;
osstr << _title << " (" << (int((1.0f / _delta_time_smoothed) * 10.0f) / 10.0f)
<< " FPS, ";
osstr << _title << " (" << (int((1.0f / _delta_time_smoothed) * 10.0f) / 10.0f) << " FPS, ";
osstr << (int(_delta_time_smoothed * 10000.0f) / 10.0f) << " ms/frame, ";
osstr << (int(_cpu_delta_time_smoothed * 10000.0f) / 10.0f) << " ms/frame [cpu])";
......@@ -150,7 +144,7 @@ namespace mirrage::graphic {
case Fullscreen::yes: return SDL_WINDOW_FULLSCREEN;
case Fullscreen::yes_borderless: return SDL_WINDOW_FULLSCREEN_DESKTOP;
}
MIRRAGE_FAIL("Unexpected fullscreen enum value: " << (int) fullscreen);
MIRRAGE_FAIL("Unexpected fullscreen enum value: " << static_cast<int>(fullscreen));
}();
SDL_SetWindowFullscreen(_window.get(), fs_type);
......
......@@ -12,11 +12,11 @@ namespace mirrage::gui {
c = nk_color_picker(ctx, c, hasAlpha ? NK_RGBA : NK_RGB);
nk_layout_row_dynamic(ctx, 14, 1);
c.r = (nk_byte) nk_propertyi(ctx, "#R:", 0, c.r, 255, 1, 1);
c.g = (nk_byte) nk_propertyi(ctx, "#G:", 0, c.g, 255, 1, 1);
c.b = (nk_byte) nk_propertyi(ctx, "#B:", 0, c.b, 255, 1, 1);
c.r = static_cast<nk_byte>(nk_propertyi(ctx, "#R:", 0, c.r, 255, 1, 1));
c.g = static_cast<nk_byte>(nk_propertyi(ctx, "#G:", 0, c.g, 255, 1, 1));
c.b = static_cast<nk_byte>(nk_propertyi(ctx, "#B:", 0, c.b, 255, 1, 1));
if(hasAlpha) {
c.a = (nk_byte) nk_propertyi(ctx, "#A:", 0, c.a, 255, 1, 1);
c.a = static_cast<nk_byte>(nk_propertyi(ctx, "#A:", 0, c.a, 255, 1, 1));
}
nk_combo_end(ctx);
......@@ -28,7 +28,9 @@ namespace mirrage::gui {
} // namespace
bool color_picker(nk_context* ctx, util::Rgb& color, int width, float factor) {
nk_color c = nk_rgb(color.r * 255 / factor, color.g * 255 / factor, color.b * 255 / factor);
nk_color c = nk_rgb(static_cast<int>(color.r * 255 / factor),
static_cast<int>(color.g * 255 / factor),
static_cast<int>(color.b * 255 / factor));
if(color_picker(ctx, c, width, false)) {
auto newColor = util::Rgb{c.r / 255.f * factor, c.g / 255.f * factor, c.b / 255.f * factor};
......@@ -42,10 +44,10 @@ namespace mirrage::gui {
}
bool color_picker(nk_context* ctx, util::Rgba& color, int width, float factor) {
nk_color c = nk_rgba(color.r * 255 / factor,
color.g * 255 / factor,
color.b * 255 / factor,
color.a * 255 / factor);
nk_color c = nk_rgba(static_cast<int>(color.r * 255 / factor),
static_cast<int>(color.g * 255 / factor),
static_cast<int>(color.b * 255 / factor),
static_cast<int>(color.a * 255 / factor));
if(color_picker(ctx, c, width, true)) {
auto newColor = util::Rgba{
......
......@@ -287,7 +287,9 @@ namespace mirrage::gui {
auto cmd = static_cast<const nk_draw_command*>(nullptr);
int offset = 0;
nk_draw_foreach(cmd, &ctx, &commands.buffer) {
for(cmd = nk__draw_begin(&ctx, &commands.buffer); cmd;
cmd = nk__draw_next(cmd, &commands.buffer, &ctx)) {
if(cmd->elem_count == 0)
continue;
......
......@@ -65,9 +65,8 @@ namespace mirrage::util {
#define CLEANUP_CONCATENATE(s1, s2) CLEANUP_CONCATENATE_DIRECT(s1, s2)
#define CLEANUP_ANONYMOUS_VARIABLE(str) CLEANUP_CONCATENATE(str, __LINE__)
#define ON_EXIT \
auto CLEANUP_ANONYMOUS_VARIABLE(_on_scope_exit) = \
::mirrage::util::detail::cleanup_scope_guard() + [&]
#define ON_EXIT \
auto CLEANUP_ANONYMOUS_VARIABLE(_on_scope_exit) = ::mirrage::util::detail::cleanup_scope_guard() + [&]
template <typename T>
......@@ -269,8 +268,7 @@ namespace mirrage::util {
public:
tracking_ptr() = default;
tracking_ptr(trackable<T>& t)
: _trackable(t._get_obj_addr())
, _last_seen_revision(_trackable ? _trackable->revision : 0) {}
: _trackable(t._get_obj_addr()), _last_seen_revision(_trackable ? _trackable->revision : 0) {}
tracking_ptr(const tracking_ptr<T>& t) = default;
tracking_ptr(tracking_ptr<T>&& t) = default;
......@@ -418,7 +416,7 @@ namespace mirrage::util {
struct iterator : std::iterator<std::random_access_iterator_tag, T, T> {
T p;
T s;
constexpr iterator(T v, T s = 1) noexcept : p(v), s(s){};
constexpr iterator(T v, T s = 1) noexcept : p(v), s(s) {}
constexpr iterator(const iterator&) noexcept = default;
constexpr iterator(iterator&&) noexcept = default;
iterator& operator++() noexcept {
......@@ -491,8 +489,7 @@ namespace mirrage::util {
return {rbegin(c), rend(c)};
}
template <class Container, typename = std::enable_if_t<!std::is_arithmetic<Container>::value>>
auto range_reverse(const Container& c)
-> iter_range<typename Container::const_reverse_iterator> {
auto range_reverse(const Container& c) -> iter_range<typename Container::const_reverse_iterator> {
using namespace std;
return {rbegin(c), rend(c)};
}
......@@ -508,7 +505,7 @@ namespace mirrage::util {
typedef Type& reference;
cast_iterator(Iter iter) : iter(iter){};
cast_iterator(Iter iter) : iter(iter) {}
reference operator*() { return *reinterpret_cast<pointer>(*iter); }
pointer operator->() { return reinterpret_cast<pointer>(*iter); }
......
......@@ -172,8 +172,8 @@ namespace mirrage::util {
// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4.
void MD5::decode(uint4 output[], const uint1 input[], size_type len) {
for(unsigned int i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((uint4) input[j]) | (((uint4) input[j + 1]) << 8) | (((uint4) input[j + 2]) << 16)
| (((uint4) input[j + 3]) << 24);
output[i] = static_cast<uint4>(input[j]) | (static_cast<uint4>(input[j + 1]) << 8)
| (static_cast<uint4>(input[j + 2]) << 16) | (static_cast<uint4>(input[j + 3]) << 24);
}
//////////////////////////////
......@@ -316,7 +316,9 @@ namespace mirrage::util {
//////////////////////////////
// for convenience provide a verson with signed char
void MD5::update(const char input[], size_type length) { update((const unsigned char*) input, length); }
void MD5::update(const char input[], size_type length) {
update(reinterpret_cast<const unsigned char*>(input), length);
}
//////////////////////////////
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment