From 21fefa5b44db3d1702470a61e9daed440cdde757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aras=20Pranckevi=C4=8Dius?= Date: Tue, 4 Apr 2023 21:18:57 +0300 Subject: [PATCH 1/2] Fix warnings with -Wundef - FASTFLOAT_ALLOWS_LEADING_PLUS and FASTFLOAT_SKIP_WHITE_SPACE are not defined by default, and compiling with -Wundef is emitting warnigns like "FASTFLOAT_ALLOWS_LEADING_PLUS is not defined, evaluates to 0". - Likewise for FASTFLOAT_VISUAL_STUDIO, change checks to use #ifdef for that like in other places. - __cpp_lib_bit_cast and __cpp_lib_is_constant_evaluated are not defined pre-C++20, and are emitting a warning too. --- include/fast_float/ascii_number.h | 2 +- include/fast_float/constexpr_feature_detect.h | 4 ++-- include/fast_float/float_common.h | 2 +- include/fast_float/parse_number.h | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/fast_float/ascii_number.h b/include/fast_float/ascii_number.h index 72b8098..b7fcc9b 100644 --- a/include/fast_float/ascii_number.h +++ b/include/fast_float/ascii_number.h @@ -116,7 +116,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, parse_ answer.valid = false; answer.too_many_digits = false; answer.negative = (*p == '-'); -#if FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default +#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default if ((*p == '-') || (*p == '+')) { #else if (*p == '-') { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here diff --git a/include/fast_float/constexpr_feature_detect.h b/include/fast_float/constexpr_feature_detect.h index 9ec8611..ba8b65c 100644 --- a/include/fast_float/constexpr_feature_detect.h +++ b/include/fast_float/constexpr_feature_detect.h @@ -14,13 +14,13 @@ #define FASTFLOAT_CONSTEXPR14 #endif -#if __cpp_lib_bit_cast >= 201806L +#if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L #define FASTFLOAT_HAS_BIT_CAST 1 #else #define FASTFLOAT_HAS_BIT_CAST 0 #endif -#if __cpp_lib_is_constant_evaluated >= 201811L +#if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L #define FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 1 #else #define FASTFLOAT_HAS_IS_CONSTANT_EVALUATED 0 diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index c878486..0f81f1a 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -481,7 +481,7 @@ void to_float(bool negative, adjusted_mantissa am, T &value) { #endif } -#if FASTFLOAT_SKIP_WHITE_SPACE // disabled by default +#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default template struct space_lut { static constexpr bool value[] = { diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index 6e4f6eb..5c28910 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -30,7 +30,7 @@ parse_infnan(const char *first, const char *last, T &value) noexcept { minusSign = true; ++first; } -#if FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default +#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default if (*first == '+') { ++first; } @@ -109,7 +109,7 @@ fastfloat_really_inline bool rounds_to_nearest() noexcept { // // Note: This may fail to be accurate if fast-math has been // enabled, as rounding conventions may not apply. - #if FASTFLOAT_VISUAL_STUDIO + #ifdef FASTFLOAT_VISUAL_STUDIO # pragma warning(push) // todo: is there a VS warning? // see https://stackoverflow.com/questions/46079446/is-there-a-warning-for-floating-point-equality-checking-in-visual-studio-2013 @@ -121,7 +121,7 @@ fastfloat_really_inline bool rounds_to_nearest() noexcept { # pragma GCC diagnostic ignored "-Wfloat-equal" #endif return (fmini + 1.0f == 1.0f - fmini); - #if FASTFLOAT_VISUAL_STUDIO + #ifdef FASTFLOAT_VISUAL_STUDIO # pragma warning(pop) #elif defined(__clang__) # pragma clang diagnostic pop @@ -148,7 +148,7 @@ from_chars_result from_chars_advanced(const char *first, const char *last, from_chars_result answer; -#if FASTFLOAT_SKIP_WHITE_SPACE // disabled by default +#ifdef FASTFLOAT_SKIP_WHITE_SPACE // disabled by default while ((first != last) && fast_float::is_space(uint8_t(*first))) { first++; } From 24374ece716db48f974f49da4aa5851aa371cfa9 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Tue, 4 Apr 2023 14:27:06 -0400 Subject: [PATCH 2/2] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0b57a5b..1327f5a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ + ## fast_float number parsing library: 4x faster than strtod +[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/fast_float.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:fast_float) +[![VS17-CI](https://github.com/fastfloat/fast_float/actions/workflows/vs17-ci.yml/badge.svg)](https://github.com/fastfloat/fast_float/actions/workflows/vs17-ci.yml) +[![Ubuntu 22.04 CI (GCC 11)](https://github.com/fastfloat/fast_float/actions/workflows/ubuntu22.yml/badge.svg)](https://github.com/fastfloat/fast_float/actions/workflows/ubuntu22.yml) The fast_float library provides fast header-only implementations for the C++ from_chars functions for `float` and `double` types. These functions convert ASCII strings representing