I presume this flymake-ghc
thing does not enable the C preprocessor while checking. To fix it, add the following to the top of affected Haskell files::
{-# LANGUAGE CPP #-}
This pragma enables the preprocessor for the containing file.
Generally, that's actually the preferred way to enable Haskell language options and extensions, because this way they are confined to files that actually require them.