Go to the first, previous, next, last section, table of contents.

Related to the C pre-processor

The C pre-processor `cpp' is run over your Haskell code only if the `-cpp' option is given. Unless you are building a large system with significant doses of conditional compilation, you really shouldn't need it.

`-D<foo>':
Define macro `<foo>' in the usual way. NB: does not affect `-D' macros passed to the C compiler when compiling via C! For those, use the `-optc-Dfoo' hack...
`-U<foo>':
Undefine macro `<foo>' in the usual way.
`-I<dir>':
Specify a directory in which to look for `#include' files, in the usual UNIX/C way.

The `ghc' driver pre-defines several macros:

`__HASKELL1__':
If defined to n, that means GHC supports the Haskell language defined in the Haskell report version 1.n. Currently 2. NB: This macro is set both when pre-processing Haskell source and when pre-processing generated C (`.hc') files. If you give the `-fhaskell-1.3' flag, then `__HASKELL1__' is set to 3. Obviously.
`__GLASGOW_HASKELL__':
For version n of the GHC system, this will be `#define'd to 100 * n. So, for version 0.26, it is 26. This macro is only set when pre-processing Haskell source. (Not when pre-processing generated C.) 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: `__YALE_HASKELL__' for Yale Haskell, `__HBC__' for Chalmers HBC, and `__GOFER__' for Gofer [I think].)
`__CONCURRENT_HASKELL__':
Only defined when `-concurrent' is in use! This symbol is defined when pre-processing Haskell (input) and pre-processing C (GHC output).
`__PARALLEL_HASKELL__':
Only defined when `-parallel' is in use! This symbol is defined when pre-processing Haskell (input) and pre-processing C (GHC output).

Options other than the above can be forced through to the C pre-processor with the `-opt' flags (see section See section Forcing options to a particular phase.).

A small word of warning: `-cpp' is not friendly to "string gaps".


Go to the first, previous, next, last section, table of contents.