Closed tstenner closed 3 years ago
This patch can be simplified without introducing a new __MINGW32__
branch by simply changing #ifdef _WIN32
to #ifdef _MSC_VER
.
The reason this patch is needed in the first place is because almost always loguru uses _WIN32
when _MSC_VER
would be better i.e. checking for compiler is better than checking for a platform.
@legends2k It can't, because the environment variable with the home directory path is USERPROFILE
on Windows (Mingw32 + MSVC), but HOME
everywhere else. The check could be split into two parts (WIN32
->USERPROFILE
/HOME
, _MSC_VER
->_dupenv_s
/getenv
), but that won't make it any shorter.
@tstenner Agreed on the shorter part and about Windows having different $HOME
. However, not introducing __MINGW32__
would be cleaner; MINGW's after all a Windows port of GCC.
_dupenv_s
isn't available when compiling with MinGW (e.g. #128). This PR retrieves the Windows-specificUSERPROFILE
environment variable with the defaultgetenv
function.Tested with MinGW 7.3.0 and MSVC14.22.