Skip to content

Commit

Permalink
Partial GCC compatibility improvements (#1234)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvinhochun committed Nov 21, 2022
1 parent 37bd17f commit 530d383
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions cppwinrt/pch.h
@@ -1,5 +1,6 @@
#pragma once

#include <utility>
#include "cmd_reader.h"
#include <winmd_reader.h>
#include "task_group.h"
Expand Down
1 change: 1 addition & 0 deletions cppwinrt/text_writer.h
Expand Up @@ -6,6 +6,7 @@
#include <sstream>
#include <string>
#include <string_view>
#include <vector>

namespace cppwinrt
{
Expand Down
2 changes: 1 addition & 1 deletion strings/base_chrono.h
Expand Up @@ -47,7 +47,7 @@ WINRT_EXPORT namespace winrt

static time_point from_time_t(time_t time) noexcept
{
return from_sys(std::chrono::system_clock::from_time_t(time));
return std::chrono::time_point_cast<duration>(from_sys(std::chrono::system_clock::from_time_t(time)));
}

static file_time to_file_time(time_point const& time) noexcept
Expand Down
9 changes: 8 additions & 1 deletion strings/base_includes.h
Expand Up @@ -6,6 +6,7 @@
#include <charconv>
#include <chrono>
#include <cstddef>
#include <cstring>
#include <iterator>
#include <map>
#include <memory>
Expand All @@ -20,6 +21,10 @@
#include <utility>
#include <vector>

#if __has_include(<version>)
#include <version>
#endif

#if __has_include(<windowsnumerics.impl.h>)
#define WINRT_IMPL_NUMERICS
#include <directxmath.h>
Expand Down Expand Up @@ -50,7 +55,7 @@ namespace winrt::impl
using suspend_never = std::suspend_never;
}

#else
#elif __has_include(<experimental/coroutine>)

#include <experimental/coroutine>

Expand All @@ -63,4 +68,6 @@ namespace winrt::impl
using suspend_never = std::experimental::suspend_never;
}

#else
#error C++/WinRT requires coroutine support, which is currently missing. Try enabling C++20 in your compiler.
#endif
4 changes: 2 additions & 2 deletions strings/base_string_operators.h
Expand Up @@ -55,9 +55,9 @@ WINRT_EXPORT namespace winrt
return left < std::wstring_view(right);
}

bool operator<(hstring const& left, nullptr_t) = delete;
bool operator<(hstring const& left, std::nullptr_t) = delete;

bool operator<(nullptr_t, hstring const& right) = delete;
bool operator<(std::nullptr_t, hstring const& right) = delete;
inline bool operator!=(hstring const& left, hstring const& right) noexcept { return !(left == right); }
inline bool operator>(hstring const& left, hstring const& right) noexcept { return right < left; }
inline bool operator<=(hstring const& left, hstring const& right) noexcept { return !(right < left); }
Expand Down

0 comments on commit 530d383

Please sign in to comment.