Skip to content

Commit

Permalink
refs #38, switched to pragma based fix, as it seams the most widely a…
Browse files Browse the repository at this point in the history
…ccepted way.
  • Loading branch information
gulrak committed Nov 23, 2019
1 parent c37d756 commit 2c3242a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,14 @@ GHC_INLINE void create_symlink(const path& target_name, const path& new_symlink,
ec = detail::make_error_code(detail::portable_error::not_supported);
return;
}
static CreateSymbolicLinkW_fp api_call = reinterpret_cast<CreateSymbolicLinkW_fp>(reinterpret_cast<void*>(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateSymbolicLinkW")));
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif
static CreateSymbolicLinkW_fp api_call = reinterpret_cast<CreateSymbolicLinkW_fp>(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateSymbolicLinkW"));
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
if (api_call) {
if (api_call(detail::fromUtf8<std::wstring>(new_symlink.u8string()).c_str(), detail::fromUtf8<std::wstring>(target_name.u8string()).c_str(), to_directory ? 1 : 0) == 0) {
auto result = ::GetLastError();
Expand All @@ -1619,7 +1626,14 @@ GHC_INLINE void create_symlink(const path& target_name, const path& new_symlink,

GHC_INLINE void create_hardlink(const path& target_name, const path& new_hardlink, std::error_code& ec)
{
static CreateHardLinkW_fp api_call = reinterpret_cast<CreateHardLinkW_fp>(reinterpret_cast<void*>(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateHardLinkW")));
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif
static CreateHardLinkW_fp api_call = reinterpret_cast<CreateHardLinkW_fp>(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateHardLinkW"));
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
if (api_call) {
if (api_call(detail::fromUtf8<std::wstring>(new_hardlink.u8string()).c_str(), detail::fromUtf8<std::wstring>(target_name.u8string()).c_str(), NULL) == 0) {
ec = detail::make_system_error();
Expand Down

0 comments on commit 2c3242a

Please sign in to comment.