diff --git a/src/config.cc b/src/config.cc index 212ec56..aa5c7c1 100644 --- a/src/config.cc +++ b/src/config.cc @@ -28,10 +28,14 @@ Config::Config() { } #ifdef _WIN32 - terminal.msys2_mingw_path=boost::filesystem::path(std::getenv("WD")).parent_path().parent_path().parent_path(); - std::string msystem=std::getenv("MSYSTEM"); - std::transform(msystem.begin(), msystem.end(), msystem.begin(), ::tolower); - terminal.msys2_mingw_path/=msystem; + auto env_WD=std::getenv("WD"); + auto env_MSYSTEM=std::getenv("MSYSTEM"); + if(env_WD!=NULL && env_MSYSTEM!=NULL) { + terminal.msys2_mingw_path=boost::filesystem::path(env_WD).parent_path().parent_path().parent_path(); + std::string msystem=env_MSYSTEM; + std::transform(msystem.begin(), msystem.end(), msystem.begin(), ::tolower); + terminal.msys2_mingw_path/=msystem; + } #endif } diff --git a/src/source_clang.cc b/src/source_clang.cc index a8397b6..2130993 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -200,7 +200,8 @@ std::vector Source::ClangViewParse::get_compilation_commands() { arguments.emplace_back("-I/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1"); //Added for OS X 10.11 #endif #ifdef _WIN32 - arguments.emplace_back("-I"+(Config::get().terminal.msys2_mingw_path/"lib/clang"/clang_version/"include").string()); + if(!Config::get().terminal.msys2_mingw_path.empty()) + arguments.emplace_back("-I"+(Config::get().terminal.msys2_mingw_path/"lib/clang"/clang_version/"include").string()); #endif } arguments.emplace_back("-fretain-comments-from-system-headers");