From e863b81ade5f606c1fc6117c6df5f635a95c5864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1=80=20=D0=A7?= =?UTF-8?q?=D0=B8=D0=B6?= Date: Fri, 1 Mar 2024 15:07:15 +0100 Subject: [PATCH] add clang 16b support --- .github/workflows/cmake-multi-platform.yml | 4 ++-- srcbpatch/bpatchfolders.cpp | 2 +- srcbpatch/coloredconsole.cpp | 2 +- srcbpatch/fileprocessing.cpp | 8 ++++++++ testbpatch/test.cpp | 12 ++++++------ 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 87c098d..1672616 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -23,8 +23,8 @@ jobs: # # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-latest, windows-latest, macos-14] - build_type: [Release, Debug] + os: [macos-14] + build_type: [Release,] c_compiler: [gcc, cl, clang] include: - os: windows-latest diff --git a/srcbpatch/bpatchfolders.cpp b/srcbpatch/bpatchfolders.cpp index 05a2057..9b55794 100644 --- a/srcbpatch/bpatchfolders.cpp +++ b/srcbpatch/bpatchfolders.cpp @@ -2,7 +2,7 @@ #include "fileprocessing.h" #include "bpatchfolders.h" -#ifdef __linux__ +#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__))) #include #else #include diff --git a/srcbpatch/coloredconsole.cpp b/srcbpatch/coloredconsole.cpp index 21e40ad..bc35cda 100644 --- a/srcbpatch/coloredconsole.cpp +++ b/srcbpatch/coloredconsole.cpp @@ -2,7 +2,7 @@ #include #include "coloredconsole.h" -#ifndef __linux__ +#if !defined(__linux__) && !((defined(__APPLE__) && defined(__MACH__))) #include #endif diff --git a/srcbpatch/fileprocessing.cpp b/srcbpatch/fileprocessing.cpp index 3a4128c..b50825d 100644 --- a/srcbpatch/fileprocessing.cpp +++ b/srcbpatch/fileprocessing.cpp @@ -24,11 +24,15 @@ using namespace std::filesystem; FileProcessing::FileProcessing(const char* fname, const char* mode) { +#if !defined(__linux__) && !(defined(__APPLE__) && defined(__MACH__)) #pragma warning(disable: 4996) // I would like to use fopen instead of fopen_s, because // 1. I would like to write fast code // 2. MSVS compiler does not respect C++ standard and __STDC_LIB_EXT1__ define +#endif if (stream_ = fopen(fname, mode); nullptr == stream_) +#if !defined(__linux__) && !(defined(__APPLE__) && defined(__MACH__)) #pragma warning(default: 4996) +#endif { throw filesystem_error(fio_errors[0], filesystem::path(fname), error_code()); } @@ -59,6 +63,8 @@ span ReadFileProcessing::ReadData(const span place) { #ifdef __linux__ const size_t readed = fread_unlocked(place.data(), sizeof(*place.data()), place.size(), stream_); +#elif defined(__APPLE__) && defined(__MACH__) + const size_t readed = fread(place.data(), sizeof(*place.data()), place.size(), stream_); #else const size_t readed = _fread_nolock(place.data(), sizeof(*place.data()), place.size(), stream_); #endif @@ -101,6 +107,8 @@ size_t WriteFileProcessing::WriteAndThrowIfFail(const string_view& sv) { #ifdef __linux__ const size_t written = fwrite_unlocked(sv.data(), sizeof(sv.data()[0]), sv.size(), stream_); +#elif defined(__APPLE__) && defined(__MACH__) + const size_t written = fwrite(sv.data(), sizeof(sv.data()[0]), sv.size(), stream_); #else const size_t written = _fwrite_nolock(sv.data(), sizeof(sv.data()[0]), sv.size(), stream_); #endif diff --git a/testbpatch/test.cpp b/testbpatch/test.cpp index ef6a173..1ecd54a 100644 --- a/testbpatch/test.cpp +++ b/testbpatch/test.cpp @@ -1,7 +1,7 @@ #include "pch.h" #include -#ifdef __linux__ +#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__))) #include #else #include @@ -29,7 +29,7 @@ TEST(WildCharacters, ProcessingValidTrue) } okMask[] = { -#ifdef __linux__ +#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__))) {R"(/Users/Bobby/kon?e?.txt)", R"(./kon?e?.txt)"} , {R"(../Bobby/kon*e*.*)", R"(../kon*e*.*)"} , {R"(kon*e*.*)", R"(./kon*e*.*)"} @@ -77,7 +77,7 @@ TEST(WildCharacters, ProcessingValidFalse) } okMask[] = { -#ifdef __linux__ +#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__))) {R"(/Users/Bobby/kon?e?.txt)", R"(/Users/Bobby/kon?e?.txt)"} , {R"(./../*.???)", R"(./../*.???)"} , {R"(*.*)", R"(*.*)"} @@ -111,7 +111,7 @@ TEST(WildCharacters, ProcessingInvalid) } badMask[] = { -#ifdef __linux__ +#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__))) {R"(/Users/Bo?by/kon?e?.txt)", emptySV} , {R"(../Bo*by/kon*e*.*)", emptySV} , {R"(*/kon*e*.*)", emptySV} @@ -158,7 +158,7 @@ TEST(WildCharacters, ProcessingInvalid) TEST(WildCharacters, SearchingTests) { // get full path for executable -#ifdef __linux__ +#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__))) char pathBuffer[PATH_MAX] = {0}; [[maybe_unused]] auto result = readlink(R"(/proc/self/exe)", pathBuffer, PATH_MAX); #else @@ -172,7 +172,7 @@ TEST(WildCharacters, SearchingTests) filesystem::path pathTestFolder(pathBuffer); pathTestFolder = pathTestFolder.parent_path(); -#ifdef __linux__ +#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__))) #else pathTestFolder /= ".."; // creation of Debug or Release subfolder is Window's 'EVERYTHING' #endif