From 728ad1a1e066da453ae13ee479629c00d8c2f32d Mon Sep 17 00:00:00 2001 From: Tamar Christina <tamar@zhox.com> Date: Sat, 3 Mar 2018 20:51:03 +0000 Subject: [PATCH] Conditionally define values (#5182) (cherry picked from commit 2d222368c79733f9948dc9bb952c0e7fd3453cd0) --- Cabal/Distribution/Compat/Environment.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Cabal/Distribution/Compat/Environment.hs b/Cabal/Distribution/Compat/Environment.hs index 014fad7a87..7194d720a4 100644 --- a/Cabal/Distribution/Compat/Environment.hs +++ b/Cabal/Distribution/Compat/Environment.hs @@ -31,6 +31,9 @@ import Distribution.Compat.Stack #ifdef mingw32_HOST_OS import Foreign.C +#if __GLASGOW_HASKELL__ < 708 +import Foreign.Ptr (nullPtr) +#endif import GHC.Windows #else import Foreign.C.Types @@ -123,6 +126,12 @@ unsetEnv key = withCWString key $ \k -> do err <- c_GetLastError unless (err == eRROR_ENVVAR_NOT_FOUND) $ do throwGetLastError "unsetEnv" + +eRROR_ENVVAR_NOT_FOUND :: DWORD +eRROR_ENVVAR_NOT_FOUND = 203 + +foreign import WINDOWS_CCONV unsafe "windows.h GetLastError" + c_GetLastError:: IO DWORD #else unsetEnv key = withFilePath key (throwErrnoIf_ (/= 0) "unsetEnv" . c_unsetenv) #if __GLASGOW_HASKELL__ > 706 -- GitLab