Using stringize and string concatenation in ghc preprocessing

Boespflug, Mathieu m at
Sun Aug 21 20:31:37 UTC 2016

Hi Harendra,

I ran into this very problem recently. Turns out -traditional knows string
concatenation too. I seem to remember learning this by browsing the GHC
source code, but now I can't find any occurrence of this pattern. But
here's an example of how to do string concatenation with CPP in
-traditional mode:


Mathieu Boespflug
Founder at

On 20 August 2016 at 20:33, Brandon Allbery <allbery.b at> wrote:

> On Sat, Aug 20, 2016 at 2:27 PM, Harendra Kumar <harendra.kumar at>
> wrote:
>> But "-optP" seems to only append to the flags that GHC already passes and
>> gcc has no "-no-traditional" option to undo the effect of the
>> "-traditional" that GHC has already passed. I think "-optP" should override
>> the flags passed by ghc rather than appending to them. Is there a reason
>> not to do that?
>> Is there any other better way to achieve this? What is the standard way
>> of doing this if any?
> Removing -traditional will break much Haskell source. Go look at the
> history of clang with ghc (clang doesn't do -traditional) to see what
> happens. (tl;dr: without -traditional, cpp knows too much about what
> constitutes valid C, and mangles and/or throws errors on valid Haskell that
> doesn't lex the way C does.)
> You might want to look at cpphs as an alternative preprocessor. There are
> some ancient K&R-era hacks that could be used if absolutely necessary, but
> cpphs should be a much simpler and cleaner solution.
> --
> brandon s allbery kf8nh                               sine nomine
> associates
> allbery.b at
> ballbery at
> unix, openafs, kerberos, infrastructure, xmonad
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list