diff --git a/kernel/io.cc b/kernel/io.cc index 078fa139c..a82f88a62 100644 --- a/kernel/io.cc +++ b/kernel/io.cc @@ -155,19 +155,13 @@ std::string get_base_tmpdir() } #if defined(_WIN32) -# ifdef __MINGW32__ char longpath[MAX_PATH + 1]; char shortpath[MAX_PATH + 1]; -# else - WCHAR longpath[MAX_PATH + 1]; - TCHAR shortpath[MAX_PATH + 1]; -# endif - if (!GetTempPath(MAX_PATH+1, longpath)) + if (!GetTempPathA(MAX_PATH+1, longpath)) log_error("GetTempPath() failed.\n"); - if (!GetShortPathName(longpath, shortpath, MAX_PATH + 1)) + if (!GetShortPathNameA(longpath, shortpath, MAX_PATH + 1)) log_error("GetShortPathName() failed.\n"); - for (int i = 0; shortpath[i]; i++) - tmpdir += char(shortpath[i]); + tmpdir += shortpath; #else char * var = std::getenv("TMPDIR"); if (var && strlen(var)!=0) { diff --git a/kernel/yosys.cc b/kernel/yosys.cc index f3f665833..d4e0eec8c 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -537,25 +537,17 @@ std::string proc_self_dirname() std::string proc_self_dirname() { int i = 0; -# ifdef __MINGW32__ char longpath[MAX_PATH + 1]; char shortpath[MAX_PATH + 1]; -# else - WCHAR longpath[MAX_PATH + 1]; - TCHAR shortpath[MAX_PATH + 1]; -# endif - if (!GetModuleFileName(0, longpath, MAX_PATH+1)) + if (!GetModuleFileNameA(0, longpath, MAX_PATH+1)) log_error("GetModuleFileName() failed.\n"); - if (!GetShortPathName(longpath, shortpath, MAX_PATH+1)) + if (!GetShortPathNameA(longpath, shortpath, MAX_PATH+1)) log_error("GetShortPathName() failed.\n"); while (shortpath[i] != 0) i++; while (i > 0 && shortpath[i-1] != '/' && shortpath[i-1] != '\\') shortpath[--i] = 0; - std::string path; - for (i = 0; shortpath[i]; i++) - path += char(shortpath[i]); - return path; + return shortpath; } #elif defined(EMSCRIPTEN) || defined(__wasm) std::string proc_self_dirname() diff --git a/libs/dlfcn-win32/dlfcn.cc b/libs/dlfcn-win32/dlfcn.cc index 03ed34dba..172fcb103 100644 --- a/libs/dlfcn-win32/dlfcn.cc +++ b/libs/dlfcn-win32/dlfcn.cc @@ -48,6 +48,7 @@ typedef ULONG ULONG_PTR; #ifdef _MSC_VER /* https://docs.microsoft.com/en-us/cpp/intrinsics/returnaddress */ +extern "C" void * _ReturnAddress(void); #pragma intrinsic( _ReturnAddress ) #else /* https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html */