diff --git a/src/loguru.cpp b/src/loguru.cpp index 4b5fe3d4127b242c727f54d0f26601507609d567..28771d2307224fae870ab083ccf402b895385c54 100644 --- a/src/loguru.cpp +++ b/src/loguru.cpp @@ -18,6 +18,36 @@ #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #endif // __GNUC__ +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +#include <stdlib.h> + +// strdup() not available for UWP apps +char* strdup_uwp_workaround_(const char* str_in) { + unsigned int size_inc = 64; + unsigned int size = 32; + unsigned int cnt = 0; + + char* str_out = static_cast<char*>(malloc(size)); + do { + if (cnt == size) { + size += size_inc; + str_out = static_cast<char*>(realloc(str_out, size)); + + size_inc = 2*size_inc; + } + + str_out[cnt] = str_in[cnt]; + + } while (str_in[cnt++] != '\0'); + + return str_out; +} + +#define strdup strdup_uwp_workaround_ + +#endif + + #define LOGURU_REPLACE_GLOG 1 #include <ftl/lib/loguru.hpp> diff --git a/src/uri.cpp b/src/uri.cpp index d28bbba8eb4f4531d1574175aa4f768fa6ccc058..efa5b6d0a8a8ffa66ba4629d54bb8850be773ce4 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -43,8 +43,8 @@ std::string get_home_dir() { #if defined(WIN32) const char* homeDrive = std::getenv("HOMEDRIVE"); const char* homePath = std::getenv("HOMEPATH"); - return string((homeDrive) ? homeDrive : "") - + string((homePath) ? homePath : ""); + return std::string((homeDrive) ? homeDrive : "") + + std::string((homePath) ? homePath : ""); #else return std::getenv("HOME"); #endif