Hello, GHC (Haskell compiler) is using builtin gcc's cpp for its cpp capability. The problem is a little bit different behaviour on different platform which I observed. As one of GHC's testcases completely unrelated to gcc's cpp we use:
{-# LANGUAGE CPP #-} module T7145b ( A.Applicative(pure) ) where import qualified Control.Applicative as A pure :: () pure = () now, internally GHC calls GCC's cpp on this file with some -Is and following options (-I <dir> removed for brevity): /usr/bin/gcc -E -undef -traditional '-D__GLASGOW_HASKELL__=709' '-Dsolaris2_BUILD_OS=1' '-Di386_BUILD_ARCH=1' '-Dsolaris2_HOST_OS=1' '-Di386_HOST_ARCH=1' -x assembler-with-cpp T7145b.hs -o /tmp/ghc2662_0/ghc2662_1.hscpp the problem is that produced code looks: {-# LANGUAGE CPP #-} module T7145b ( A.Applicative(pure) ) where import qualified Control.Applicative as A pure :: () pure = () so exact copy of the input file. Now, this is with Solaris 11.1 distributed GNU C 4.5.2. I've tested also 4.6.0, 4.7.1 and 4.8.2 built by myself on the same platform and all those exhibit the same behaviour. Now, if I try the same on Ubuntu 14.04 LTS which provides GNU C 4.8.2, then I get the expected output which contains # 1 "T7145b.hs" # 1 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 17 "/usr/include/stdc-predef.h" 3 4 [ empty lines cut] # 1 "<command-line>" 2 # 1 "T7145b.hs" {-# LANGUAGE CPP #-} module T7145b ( A.Applicative(pure) ) where import qualified Control.Applicative as A pure :: () pure = () Now my question is what exactly is expected behaviour and what not. I'm mainly interested in this # 1 "7145b.hs" since we need it to get the source file name right in following GHC emitted warning/error messages. Is there any way how to enable those CPP marks even on Solaris? Or is Ubuntu using some distro specific patch to enable this behaviour and the behaviour itself is deprecated? Thanks! Karel