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 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 4. NB: This macro is set both when pre-processing Haskell source and when pre-processing generated C (`.hc') files.
`__GLASGOW_HASKELL__':
For version n of the GHC system, this will be `#define'd to 100 * n. So, for version 2.02, it is 202. 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: `__HUGS__' for Hugs and `__HBC__' for Chalmers.)
`__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".. In other words, strings such as the following:

        strmod = "\
        \ p \
        \ "

don't work with `-cpp'; `/usr/bin/cpp' elides the backslash-newline pairs.

However, it appears that if you add a space at the end of the line, then `cpp' (at least GNU `cpp' and possibly other `cpp's) leaves the backslash-space pairs alone and the string gap works as expected.


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