Skip to content

Commit d7d83de

Browse files
committed
Fix Bluetcl use of GHC macros, for older GHC
The __GLASGOW_HASKELL_FULL_VERSION__ CPP macro was introduced in 9.0, so for earlier versions, we need to construct it from other macros that have existed since at least 7.10.
1 parent d6b6ceb commit d7d83de

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/comp/bluetcl.hs

+16-1
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,24 @@ versionGrammar = (tclcmd "version" namespace helpStr longHelpStr) .+.
415415
versionNum :: [String] -> IO HTclObj
416416
versionNum [] = versionNum ["bsc"]
417417
versionNum ["bsc"] = return $ TLst [TStr versionname, TStr buildVersion]
418-
versionNum ["ghc"] = return $ TStr __GLASGOW_HASKELL_FULL_VERSION__
418+
versionNum ["ghc"] = return $ TStr ghcVersionStr
419419
versionNum xs = internalError $ "versionNum: grammar mismatch: " ++ (show xs)
420420

421+
ghcVersionStr :: String
422+
#if defined(__GLASGOW_HASKELL_FULL_VERSION__)
423+
ghcVersionStr = __GLASGOW_HASKELL_FULL_VERSION__
424+
#else
425+
ghcVersionStr =
426+
let version_raw :: Int = __GLASGOW_HASKELL__
427+
(major, minor) :: (Int, Int) = version_raw `divMod` 100
428+
#if defined(__GLASGOW_HASKELL_PATCHLEVEL1__)
429+
patch1 :: Int = __GLASGOW_HASKELL_PATCHLEVEL1__
430+
in show major ++ "." ++ show minor ++ "." ++ show patch1
431+
#else
432+
in show major ++ "." ++ show minor
433+
#endif
434+
#endif
435+
421436
--------------------------------------------------------------------------------
422437
-- flags
423438

0 commit comments

Comments
 (0)