Skip to content

Commit

Permalink
fix warnings with -Wundef
Browse files Browse the repository at this point in the history
  • Loading branch information
biojppm committed Feb 13, 2025
1 parent f455f20 commit ac579d5
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 46 deletions.
30 changes: 10 additions & 20 deletions .github/docker/ubuntu24.04/c4core-install
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ case $what in
$script arm-linux-gnueabihf
$script qemu
;;
g++-4.8|gcc-4.8)
g++-4.8|gcc-4.8|gcc4.8)
apt-get update
apt-get install -y \
software-properties-common
Expand All @@ -59,7 +59,7 @@ case $what in
gcc-4.8 --version
g++-4.8 --version
;;
g++-4.9|gcc-4.9)
g++-4.9|gcc-4.9|gcc4.9)
apt-get update
apt-get install -y \
wget \
Expand All @@ -74,7 +74,7 @@ case $what in
gcc-4.9 --version
g++-4.9 --version
;;
g++-5|gcc-5)
g++-5|gcc-5|gcc5)
apt-get update
apt-get install -y \
wget \
Expand Down Expand Up @@ -340,65 +340,55 @@ case $what in
arm-none-eabi-gcc --version
arm-none-eabi-g++ --version
;;
armv7)
arm-linux-gnueabihf)
armv7|arm-linux-gnueabihf)
apt-get update
apt-get install -y \
gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf
arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-g++ --version
;;
armv6)
arm-linux-gnueabi)
armv6|arm-linux-gnueabi)
apt-get update
apt-get install -y \
gcc-arm-linux-gnueabi \
g++-arm-linux-gnueabi
arm-linux-gnueabi-gcc --version
arm-linux-gnueabi-g++ --version
;;
aarch64)
aarch64-linux-gnu)
aarch64|aarch64-linux-gnu)
apt-get update
apt-get install -y \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu
aarch64-linux-gnu-gcc --version
aarch64-linux-gnu-g++ --version
;;
s390)
s390x)
s390x-linux-gnu)
s390|s390x|s390x-linux-gnu)
apt-get update
apt-get install -y \
gcc-s390x-linux-gnu \
g++-s390x-linux-gnu
s390x-linux-gnu-gcc --version
s390x-linux-gnu-g++ --version
;;
ppc64le)
powerpc64le)
ppc64le-linux-gnu)
ppc64le|powerpc64le|ppc64le-linux-gnu)
apt-get update
apt-get install -y \
gcc-powerpc64le-linux-gnu \
g++-powerpc64le-linux-gnu
powerpc64le-linux-gnu-gcc --version
powerpc64le-linux-gnu-g++ --version
;;
ppc64)
powerpc64)
ppc64-linux-gnu)
ppc64|powerpc64|ppc64-linux-gnu)
apt-get update
apt-get install -y \
gcc-powerpc64-linux-gnu \
g++-powerpc64-linux-gnu
powerpc64-linux-gnu-gcc --version
powerpc64-linux-gnu-g++ --version
;;
riscv64)
riscv64-linux-gnu)
riscv64|riscv64-linux-gnu)
apt-get update
apt-get install -y \
gcc-riscv64-linux-gnu \
Expand Down
4 changes: 2 additions & 2 deletions bm/bm_charconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ xtoa_std_to_chars(bm::State& st)
}
#endif

#if C4CORE_BM_HAVE_TOCHARS
#if defined(C4CORE_BM_HAVE_TOCHARS)
C4FOR(T, isreal)
xtoa_std_to_chars(bm::State& st)
{
Expand Down Expand Up @@ -1177,7 +1177,7 @@ atox_std_from_chars(bm::State& st)
}
#endif

#if C4CORE_BM_HAVE_TOCHARS
#if defined(C4CORE_BM_HAVE_TOCHARS)
C4FOR(T, isreal)
atox_std_from_chars(bm::State& st)
{
Expand Down
32 changes: 16 additions & 16 deletions bm/float/read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@
#endif


#if C4FLOAT_STD_ATOF
#if defined(C4FLOAT_STD_ATOF)
#include <cstdlib>
double doit(const char *s) { return atof(s); }
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_SSCANF_F
#elif defined(C4FLOAT_SSCANF_F)
float doit(const char *s) { float val; sscanf(s, "%f", &val); return val; }
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_SSCANF_D
#elif defined(C4FLOAT_SSCANF_D)
double doit(const char *s) { double val; sscanf(s, "%lf", &val); return val; }
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_IOSTREAM_F
#elif defined(C4FLOAT_IOSTREAM_F)
#include <sstream>
float doit(const char *s) { std::stringstream ss; ss << s; float val; ss >> val; return val; }
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_IOSTREAM_D
#elif defined(C4FLOAT_IOSTREAM_D)
#include <sstream>
double doit(const char *s) { std::stringstream ss; ss << s; double val; ss >> val; return val; }
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_IOSTREAM_D
#elif defined(C4FLOAT_IOSTREAM_D)
#include <sstream>
double doit(const char *s) { std::stringstream ss; ss << s; double val; ss >> val; return val; }
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_FP_F_LIMITED
#elif defined(C4FLOAT_FP_F_LIMITED)
#include <jkj/fp/from_chars/from_chars.h>
float doit(const char *s)
{
Expand All @@ -54,7 +54,7 @@ float doit(const char *s)
}
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_FP_D_LIMITED
#elif defined(C4FLOAT_FP_D_LIMITED)
#include <jkj/fp/from_chars/from_chars.h>
double doit(const char *s)
{
Expand All @@ -63,7 +63,7 @@ double doit(const char *s)
}
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_FP_F_UNLIMITED
#elif defined(C4FLOAT_FP_F_UNLIMITED)
#include <jkj/fp/from_chars/from_chars.h>
float doit(const char *s)
{
Expand All @@ -72,7 +72,7 @@ float doit(const char *s)
}
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_FP_D_UNLIMITED
#elif defined(C4FLOAT_FP_D_UNLIMITED)
#include <jkj/fp/from_chars/from_chars.h>
double doit(const char *s)
{
Expand All @@ -81,7 +81,7 @@ double doit(const char *s)
}
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_FASTFLOAT_F
#elif defined(C4FLOAT_FASTFLOAT_F)
#include <c4/ext/fast_float.hpp>
#include <cstring>
float doit(const char *s)
Expand All @@ -92,7 +92,7 @@ float doit(const char *s)
}
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_FASTFLOAT_D
#elif defined(C4FLOAT_FASTFLOAT_D)
#include <c4/ext/fast_float.hpp>
#include <cstring>
double doit(const char *s)
Expand All @@ -103,7 +103,7 @@ double doit(const char *s)
}
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_STD_FROM_CHARS_F
#elif defined(C4FLOAT_STD_FROM_CHARS_F)
#include <charconv>
#include <cstring>
float doit(const char *s)
Expand All @@ -114,7 +114,7 @@ float doit(const char *s)
}
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_STD_FROM_CHARS_D
#elif defined(C4FLOAT_STD_FROM_CHARS_D)
#include <charconv>
#include <cstring>
double doit(const char *s)
Expand All @@ -125,7 +125,7 @@ double doit(const char *s)
}
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_RYU_F
#elif defined(C4FLOAT_RYU_F)
#include <ryu/ryu_parse.h>
float doit(const char *s)
{
Expand All @@ -135,7 +135,7 @@ float doit(const char *s)
}
#define C4_TO_REAL(s) doit(s)

#elif C4FLOAT_RYU_D
#elif defined(C4FLOAT_RYU_D)
#include <ryu/ryu_parse.h>
double doit(const char *s)
{
Expand Down
2 changes: 1 addition & 1 deletion cmake
Submodule cmake updated 1 files
+1 −0 c4Project.cmake
4 changes: 4 additions & 0 deletions src/c4/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct fail_type__ {};
#else
# ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wundef"
# if !defined(__APPLE_CC__)
# if __clang_major__ >= 10
# pragma clang diagnostic ignored "-Wgnu-inline-cpp-without-extern" // debugbreak/debugbreak.h:50:16: error: 'gnu_inline' attribute without 'extern' in C++ treated as externally available, this changed in Clang 10 [-Werror,-Wgnu-inline-cpp-without-extern]
Expand All @@ -73,12 +74,15 @@ struct fail_type__ {};
# endif
# endif
# elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wundef"
# endif
# include <c4/ext/debugbreak/debugbreak.h>
# define C4_DEBUG_BREAK() if(c4::is_debugger_attached()) { ::debug_break(); }
# ifdef __clang__
# pragma clang diagnostic pop
# elif defined(__GNUC__)
# pragma GCC diagnostic pop
# endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/c4/ext/fast_float_all.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
#include <type_traits>
#include <system_error>
#ifdef __has_include
#if __has_include(<stdfloat>) && (__cplusplus > 202002L || _MSVC_LANG > 202002L)
#if __has_include(<stdfloat>) && (__cplusplus > 202002L || (defined(_MSVC_LANG) && (_MSVC_LANG > 202002L)))
#include <stdfloat>
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/c4/format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "c4/blob.hpp"


#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(__clang__)
# pragma warning(push)
# if C4_MSVC_VERSION != C4_MSVC_VERSION_2017
# pragma warning(disable: 4800) // forcing value to bool 'true' or 'false' (performance warning)
Expand Down
8 changes: 4 additions & 4 deletions test/test_charconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ csubstr underflow_by(substr buf, T val, T how_much, T radix)

TEST_CASE("charconv.to_chars_format")
{
#if C4CORE_HAVE_STD_TO_CHARS
#if defined(C4CORE_HAVE_STD_TO_CHARS)
CHECK(FTOA_FLOAT == static_cast<std::underlying_type<std::chars_format>::type>(std::chars_format::fixed));
CHECK(FTOA_SCIENT == static_cast<std::underlying_type<std::chars_format>::type>(std::chars_format::scientific));
CHECK(FTOA_FLEX == static_cast<std::underlying_type<std::chars_format>::type>(std::chars_format::general));
CHECK(FTOA_HEXA == static_cast<std::underlying_type<std::chars_format>::type>(std::chars_format::hex));
#elif !C4CORE_HAVE_FAST_FLOAT
#elif !defined(C4CORE_HAVE_FAST_FLOAT)
CHECK(FTOA_FLOAT == 'f');
CHECK(FTOA_SCIENT == 'e');
CHECK(FTOA_FLEX == 'g');
Expand Down Expand Up @@ -2254,7 +2254,7 @@ TEST_CASE("ftoa.basic")
// precision values when printing in hexadecimal format.
//
// @see https://github.com/biojppm/c4core/pull/52
#if defined(__EMSCRIPTEN__) && __EMSCRIPTEN_major__ < 3
#if defined(__EMSCRIPTEN__) && __EMSCRIPTEN__ < 3
#define _c4emscripten_alt(alt) , alt
#define _c4emscripten_alt2(alt1, alt2) , alt2
#else
Expand Down Expand Up @@ -2369,7 +2369,7 @@ TEST_CASE_TEMPLATE("atof.hexa", T, float, double)
INFO("str=" << str);
CHECK_EQ(atox(str, &rval), isok);
};
#if C4CORE_NO_FAST_FLOAT
#if defined(C4CORE_NO_FAST_FLOAT)
#define _scanf_accepts(expected) !expected
#else
#define _scanf_accepts(expected) expected
Expand Down

0 comments on commit ac579d5

Please sign in to comment.