From b64b53aeef6a52e74685d087c420e351857d00de Mon Sep 17 00:00:00 2001 From: Bob Tolbert Date: Sat, 20 Aug 2022 11:17:31 -0600 Subject: [PATCH] clean up warnings in peglib.h sprintf on Visual Studio (#243) --- CMakeLists.txt | 2 +- peglib.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff0861b..606290e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_EXTENSIONS OFF) if(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus /utf-8") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus /utf-8 /D_CRT_SECURE_NO_DEPRECATE") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") endif() diff --git a/peglib.h b/peglib.h index 2509afd..d2ad3b5 100644 --- a/peglib.h +++ b/peglib.h @@ -4738,7 +4738,7 @@ inline void enable_profiling(parser &parser, std::ostream &os) { << std::endl; auto grand_total = total_success + total_fail; - sprintf(buff, "%4s %10lu %5s %10lu %10lu %s", "", grand_total, + sprintf(buff, "%4s %10zu %5s %10zu %10zu %s", "", grand_total, "", total_success, total_fail, "Total counters"); os << buff << std::endl; @@ -4752,7 +4752,7 @@ inline void enable_profiling(parser &parser, std::ostream &os) { for (auto &[name, success, fail] : stats.items) { auto total = success + fail; auto ratio = total * 100.0 / stats.total; - sprintf(buff, "%4zu %10lu %5.2f %10lu %10lu %s", id, total, + sprintf(buff, "%4zu %10zu %5.2f %10zu %10zu %s", id, total, ratio, success, fail, name.c_str()); os << buff << std::endl; id++;