Skip to content

Commit

Permalink
Fix compilation for MSVC
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Artsishevsky <polter.rnd@gmail.com>
  • Loading branch information
polter-rnd committed Oct 10, 2024
1 parent c54914d commit fb83541
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ option(ENABLE_ANALYZERS "Static code analyzers" OFF)
add_feature_info("StaticCodeAnalysis" ENABLE_ANALYZERS "code linting and static analysis")
if(ENABLE_ANALYZERS)
set(CPPCHECK_MIN_VERSION 2.10)
set(CLANG_TIDY_MIN_VERSION 14.0)
set(CLANG_TIDY_MIN_VERSION 17.0)
set(CLANG_FORMAT_MIN_VERSION 17.0)
set(IWYU_MIN_VERSION 0.21)
include(StaticCodeAnalysis)
Expand Down
2 changes: 1 addition & 1 deletion include/log/sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class SinkDriver final {
if constexpr (std::is_void_v<typename std::invoke_result_t<T, Args...>>) {
// Void callable without arguments: there is no message, just a callback
callback(std::forward<Args>(args)...);
return;
break;
} else {
// Non-void callable without arguments: message is the return value
auto message = callback(std::forward<Args>(args)...);
Expand Down
10 changes: 8 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#include "log/sinks/ostream_sink.h"
#include "util/locale.h"

#ifndef _MSC_VER
#include <unistd.h>
#endif

#include <algorithm>
#include <chrono>
Expand Down Expand Up @@ -65,7 +67,11 @@ std::basic_string_view<T> gen_random(const int len)
L"абвгдеёжзийклмнопрстуфхцчшщъыьэюя"
L" \t";
static std::basic_string<T> tmp_s;
#ifndef _MSC_VER
static auto seed = (unsigned)time(NULL) * getpid();
#else
static auto seed = (unsigned)time(NULL) * _getpid();
#endif
tmp_s.clear();
tmp_s.reserve(len);

Expand All @@ -77,7 +83,7 @@ std::basic_string_view<T> gen_random(const int len)
return std::basic_string_view<T>{tmp_s};
}

double percentile(std::vector<double>& vectorIn, double percent)
double percentile(std::vector<double>& vectorIn, int percent)
{
auto nth = vectorIn.begin() + (percent * vectorIn.size()) / 100;
std::nth_element(vectorIn.begin(), nth, vectorIn.end());
Expand Down Expand Up @@ -162,7 +168,7 @@ auto main(int /*argc*/, char* /*argv*/[]) -> int
std::cout << "*** This is simple test for the logger ***\n";
std::cout << "==========================================\n";

#if 0
#if ENABLE_FMTLIB && __GNUC__
const std::basic_stringstream<char8_t> mystream;
Log::Logger log19{u8"uchar8 log"};
log19.add_sink<Log::OStreamSink>(
Expand Down

0 comments on commit fb83541

Please sign in to comment.