Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed build for WinRT and Android #804

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/date/tz.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

#ifndef HAS_REMOTE_API
# if USE_OS_TZDB == 0
# ifdef _WIN32
# if defined _WIN32 || defined __ANDROID__
# define HAS_REMOTE_API 0
# else
# define HAS_REMOTE_API 1
Expand Down
32 changes: 18 additions & 14 deletions src/tz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
// the current time zone. On Win32 windows.h provides a means to do it.
// gcc/mingw supports unistd.h on Win32 but MSVC does not.

#ifdef __ANDROID__
# define INSTALL .
#endif
#ifdef _WIN32
# ifdef WINAPI_FAMILY
# include <winapifamily.h>
Expand Down Expand Up @@ -183,20 +186,6 @@ static CONSTDATA char folder_delimiter = '/';
#if !USE_OS_TZDB

# ifdef _WIN32
# ifndef WINRT

namespace
{
struct task_mem_deleter
{
void operator()(wchar_t buf[])
{
if (buf != nullptr)
CoTaskMemFree(buf);
}
};
using co_task_mem_ptr = std::unique_ptr<wchar_t[], task_mem_deleter>;
}

static
std::wstring
Expand Down Expand Up @@ -227,6 +216,21 @@ convert_utf8_to_utf16(const std::string& s)
return out;
}

# ifndef WINRT

namespace
{
struct task_mem_deleter
{
void operator()(wchar_t buf[])
{
if (buf != nullptr)
CoTaskMemFree(buf);
}
};
using co_task_mem_ptr = std::unique_ptr<wchar_t[], task_mem_deleter>;
}

// We might need to know certain locations even if not using the remote API,
// so keep these routines out of that block for now.
static
Expand Down