mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
Support macOS
This allows building and running under macOS. There is still some issues with dpi but the application compiles and run now.
This commit is contained in:
@@ -18,6 +18,33 @@
|
||||
|
||||
#include "lang/token.hpp"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define off64_t off_t
|
||||
#define fopen64 fopen
|
||||
#define fseeko64 fseek
|
||||
#define ftello64 ftell
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION <= 12000
|
||||
#if __has_include(<concepts>)
|
||||
// Make sure we break when derived_from is implemented in libc++. Then we can fix a compatibility version above
|
||||
#include <concepts>
|
||||
#endif
|
||||
// libcxx 12 still doesn't have derived_from implemented, as a result we need to define it ourself using clang built-ins.
|
||||
// [concept.derived] (patch from https://reviews.llvm.org/D74292)
|
||||
namespace hex {
|
||||
template<class _Dp, class _Bp>
|
||||
concept derived_from =
|
||||
__is_base_of(_Bp, _Dp) && __is_convertible_to(const volatile _Dp*, const volatile _Bp*);
|
||||
}
|
||||
#else
|
||||
// Assume supported
|
||||
#include <concepts>
|
||||
namespace hex {
|
||||
using std::derived_from;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace hex {
|
||||
|
||||
template<typename ... Args>
|
||||
@@ -99,6 +126,19 @@ namespace hex {
|
||||
throw std::invalid_argument("Invalid value size!");
|
||||
}
|
||||
|
||||
template< class T >
|
||||
constexpr T bit_width(T x) noexcept {
|
||||
return std::numeric_limits<T>::digits - std::countl_zero(x);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr T bit_ceil(T x) noexcept {
|
||||
if (x <= 1u)
|
||||
return T(1);
|
||||
|
||||
return T(1) << bit_width(T(x - 1));
|
||||
}
|
||||
|
||||
std::vector<u8> readFile(std::string_view path);
|
||||
|
||||
class ScopeExit {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <hex.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <concepts>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "providers/provider.hpp"
|
||||
|
||||
#include <concepts>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <concepts>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "helpers/utils.hpp"
|
||||
#include "views/view.hpp"
|
||||
|
||||
struct GLFWwindow;
|
||||
@@ -19,7 +19,7 @@ namespace hex {
|
||||
|
||||
void loop();
|
||||
|
||||
template<std::derived_from<View> T, typename ... Args>
|
||||
template<derived_from<View> T, typename ... Args>
|
||||
T* addView(Args&& ... args) {
|
||||
this->m_views.emplace_back(new T(std::forward<Args>(args)...));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user