Skip to content

Commit

Permalink
Fix Bluetcl use of GHC macros, for older GHC
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
quark17 committed Feb 24, 2024
1 parent d6b6ceb commit d79e6e8
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/comp/bluetcl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,24 @@ versionGrammar = (tclcmd "version" namespace helpStr longHelpStr) .+.
versionNum :: [String] -> IO HTclObj
versionNum [] = versionNum ["bsc"]
versionNum ["bsc"] = return $ TLst [TStr versionname, TStr buildVersion]
versionNum ["ghc"] = return $ TStr __GLASGOW_HASKELL_FULL_VERSION__
versionNum ["ghc"] = return $ TStr ghcVersionStr
versionNum xs = internalError $ "versionNum: grammar mismatch: " ++ (show xs)

ghcVersionStr :: String
#if defined(__GLASGOW_HASKELL_FULL_VERSION__)
ghcVersionStr = __GLASGOW_HASKELL_FULL_VERSION__
#else
ghcVersionStr =
let version_raw :: Int = __GLASGOW_HASKELL__
(major, minor) :: (Int, Int) = version_raw `divMod` 100
#if defined(__GLASGOW_HASKELL_PATCHLEVEL1__)
patch1 :: Int = __GLASGOW_HASKELL_PATCHLEVEL1__
in show major ++ "." ++ show minor ++ "." ++ show patch1
#else
in show major ++ "." ++ show minor
#endif
#endif

--------------------------------------------------------------------------------
-- flags

Expand Down

0 comments on commit d79e6e8

Please sign in to comment.