diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt index dac330b955..21d399eee8 100644 --- a/c/CMakeLists.txt +++ b/c/CMakeLists.txt @@ -23,6 +23,8 @@ include(BuildUtils) project(adbc VERSION "${ADBC_BASE_VERSION}" LANGUAGES C CXX) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) include(CTest) diff --git a/c/driver/postgresql/copy/writer.h b/c/driver/postgresql/copy/writer.h index 320b89e6c7..32c894b5df 100644 --- a/c/driver/postgresql/copy/writer.h +++ b/c/driver/postgresql/copy/writer.h @@ -17,10 +17,12 @@ #pragma once +#include #include #include #include #include +#include #include #include @@ -237,10 +239,9 @@ class PostgresCopyNumericFieldWriter : public PostgresCopyFieldWriter { const int start_pos = digits_remaining < kDecDigits ? 0 : digits_remaining - kDecDigits; const size_t len = digits_remaining < 4 ? digits_remaining : kDecDigits; - char substr[kDecDigits + 1]; - std::memcpy(substr, decimal_string + start_pos, len); - substr[len] = '\0'; - int16_t val = static_cast(std::atoi(substr)); + const std::string_view substr{decimal_string + start_pos, len}; + int16_t val{}; + std::from_chars(substr.data(), substr.data() + substr.size(), val); if (val == 0) { if (!seen_decimal && truncating_trailing_zeros) { diff --git a/ci/scripts/cpp_clang_tidy.sh b/ci/scripts/cpp_clang_tidy.sh index 5c972ffbd5..5074223b6a 100755 --- a/ci/scripts/cpp_clang_tidy.sh +++ b/ci/scripts/cpp_clang_tidy.sh @@ -59,7 +59,6 @@ build_subproject() { -DADBC_DRIVER_SNOWFLAKE="${BUILD_DRIVER_SNOWFLAKE}" \ -DADBC_USE_ASAN="${ADBC_USE_ASAN}" \ -DADBC_USE_UBSAN="${ADBC_USE_UBSAN}" \ - -DCMAKE_CXX_STANDARD=17 \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \ -DCMAKE_INSTALL_LIBDIR=lib \