Where can I learn about #ifdef?

后端 未结 4 710
旧时难觅i
旧时难觅i 2020-12-29 03:21

I see this used often to make modules compatible with GHC and Hugs, but google is not helping me learn more about it.

What can I put inside the conditional? Can I m

4条回答
  •  旧巷少年郎
    2020-12-29 03:41

    #ifdef and friends are used by the C preprocessor (CPP). They provide a way to compile code conditionally. You can enable the use of the CPP by adding the pragma {-# LANGUAGE CPP #-} on top of a file.

    Many programs that deal with Haskell code set some macros for the preprocessor (eg. GHC sets __GLASGOW_HASKELL__ to the version of GHC), so one can conditionally compile code, for instance to use different properitary libraries for Hugs and GHC.

提交回复
热议问题