Skip to content
Snippets Groups Projects
Commit b702228c authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

workarounds for UWP build

parent 90563cf2
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment