mirror of
https://github.com/aantron/better-enums.git
synced 2025-12-06 08:46:42 +08:00
Enabled more warnings during testing.
To avoid problems with warnings in CxxTest, the extra warnings are enabled during one test (linking) that does not use CxxTest. Resolves #16.
This commit is contained in:
parent
9a754681c9
commit
cc9cce28ae
8
enum.h
8
enum.h
@ -264,7 +264,7 @@ namespace better_enums {
|
||||
template <typename T>
|
||||
BETTER_ENUMS_CONSTEXPR_ inline T _default()
|
||||
{
|
||||
return (typename T::_enumerated)0;
|
||||
return static_cast<typename T::_enumerated>(0);
|
||||
}
|
||||
|
||||
template <>
|
||||
@ -302,7 +302,7 @@ template <typename CastTo, typename Element>
|
||||
BETTER_ENUMS_CONSTEXPR_ static optional<CastTo>
|
||||
_map_index(const Element *array, optional<std::size_t> index)
|
||||
{
|
||||
return index ? (CastTo)array[*index] : optional<CastTo>();
|
||||
return index ? static_cast<CastTo>(array[*index]) : optional<CastTo>();
|
||||
}
|
||||
|
||||
#ifdef BETTER_ENUMS_VC2008_WORKAROUNDS
|
||||
@ -425,7 +425,7 @@ _select(const char *from, std::size_t from_length, std::size_t index)
|
||||
|
||||
BETTER_ENUMS_CONSTEXPR_ inline char _to_lower_ascii(char c)
|
||||
{
|
||||
return c >= 0x41 && c <= 0x5A ? (char)(c + 0x20) : c;
|
||||
return c >= 0x41 && c <= 0x5A ? static_cast<char>(c + 0x20) : c;
|
||||
}
|
||||
|
||||
BETTER_ENUMS_CONSTEXPR_ inline bool _names_match(const char *stringizedName,
|
||||
@ -1000,7 +1000,7 @@ BETTER_ENUMS_CONSTEXPR_ inline bool operator >=(const Enum &a, const Enum &b) \
|
||||
#ifndef BETTER_ENUMS_DEFAULT_CONSTRUCTOR
|
||||
# define BETTER_ENUMS_DEFAULT_CONSTRUCTOR(Enum) \
|
||||
private: \
|
||||
Enum() { }
|
||||
Enum() : _value(0) { }
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -153,13 +153,27 @@ include_directories(../extra)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
macro(add_cxx_flag_if_supported FLAG)
|
||||
check_cxx_compiler_flag("${FLAG}" HAVE_FLAG_${FLAG})
|
||||
|
||||
if(HAVE_FLAG_${FLAG})
|
||||
add_definitions(${FLAG})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(add_cxx_flag_to_target_if_supported TARGET FLAG)
|
||||
string(REPLACE "=" "_equals_" ESCAPED ${FLAG})
|
||||
string(REPLACE "+" "_plus_" ESCAPED ${ESCAPED})
|
||||
check_cxx_compiler_flag("${FLAG}" HAVE_FLAG_${ESCAPED})
|
||||
check_cxx_compiler_flag("${FLAG}" HAVE_FLAG_${FLAG})
|
||||
|
||||
if(HAVE_FLAG_${ESCAPED})
|
||||
add_definitions(${FLAG})
|
||||
if(HAVE_FLAG_${FLAG})
|
||||
get_target_property(FLAGS ${TARGET} COMPILE_FLAGS)
|
||||
if(${FLAGS} STREQUAL "FLAGS-NOTFOUND")
|
||||
set(FLAGS "")
|
||||
endif()
|
||||
set_target_properties(
|
||||
${TARGET} PROPERTIES COMPILE_FLAGS "${FLAGS} ${FLAG}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@ -169,5 +183,21 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
||||
add_cxx_flag_if_supported("-Wno-variadic-macros")
|
||||
add_cxx_flag_if_supported("-Wno-unused-const-variable")
|
||||
|
||||
add_cxx_flag_to_target_if_supported(linking "-Weverything")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wno-c++98-compat-pedantic")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wno-padded")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wno-global-constructors")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wno-old-style-cast")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wno-missing-prototypes")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wshadow")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Weffc++")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wstrict-aliasing")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wformat")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wmissing-include-dirs")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wsync-nand")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wconditionally-supported")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wconversion")
|
||||
add_cxx_flag_to_target_if_supported(linking "-Wuseless-cast")
|
||||
|
||||
add_definitions("-Werror")
|
||||
endif()
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
#ifndef _HELPER_H_
|
||||
#define _HELPER_H_
|
||||
#ifndef HELPER_H
|
||||
#define HELPER_H
|
||||
|
||||
#include "shared.h"
|
||||
|
||||
void print(Channel channel);
|
||||
|
||||
#endif // #ifndef _HELPER_H_
|
||||
#endif // #ifndef HELPER_H
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
#ifndef _SHARED_H_
|
||||
#define _SHARED_H_
|
||||
#ifndef SHARED_H
|
||||
#define SHARED_H
|
||||
|
||||
#include <enum.h>
|
||||
|
||||
BETTER_ENUM(Channel, int, Red, Green, Blue)
|
||||
|
||||
#endif // #ifndef _SHARED_H_
|
||||
#endif // #ifndef SHARED_H
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user