GHC version check in code

前端 未结 3 1830
礼貌的吻别
礼貌的吻别 2021-02-19 10:54

I\'m contributing to Alex, and it obviously depends on a lot of libraries and should compile for a lot of versions.

I need to use a function that is only available from

3条回答
  •  清酒与你
    2021-02-19 11:17

    Read the fine documentation:

    For version x.y.z of GHC, the value of __GLASGOW_HASKELL__ is the integer xyy (if y is a single digit, then a leading zero is added, so for example in version 6.2 of GHC, __GLASGOW_HASKELL__==602). More information in Section 1.4, “GHC version numbering policy”.

    With any luck, __GLASGOW_HASKELL__ will be undefined in all other implementations that support C-style pre-processing.

    (For reference: the comparable symbols for other systems are: __HUGS__ for Hugs, __NHC__ for nhc98, and __HBC__ for hbc.)

    NB. This macro is set when pre-processing both Haskell source and C source, including the C source generated from a Haskell module (i.e. .hs, .lhs, .c and .hc files).

提交回复
热议问题