cpphs (was Re: Haskell on Red Hat Enterprise...)

Andy Moran moran at galois.com
Thu Mar 17 18:03:17 EST 2005


Malcolm Wallace wrote:
> Andy Moran <moran at galois.com> writes:
> 
>>I notice that cpphs understands CPP stringification (if invoked with 
>>--hashes). Most of the gcc 3.4 failures (in fact, all of that I've seen) 
>>have to do with fooling -traditional into turning macro constants into 
>>Haskell strings, which can more readily be done with the #-operator. So, 
>>would using cpphs mean we could do away with the string gap hack?
> 
> Without seeing the examples in question, I can't say for definite, but
> cpphs /does/ preserve string gaps in source code in all cases.

Here's an example, from 6.2.1's ghc/utils/ghc-pkg/Main.hs:

-- hackery to convice cpp to splice GHC_PKG_VERSION into a string
version :: String
version = tail "\
    \ GHC_PKG_VERSION"

HEAD uses a Makefile-generated Version.hs instead. Simon M.: are all 
instances of the above trick replaced by analogues of this much neater 
mechanism?

> In addition, you can paste symbol values into strings using either the
> ANSI stringification operator (#) or the traditional behaviour of
> expansion within quotes ("SYMBOL").

So, cpphs' version of traditional is truer to tradition than gcc's, it 
seems. "gcc -E -traditional -x c" doesn't expand within quotes, which is 
why hacks like the above were introduced.

Cheers,

Andy

-- 
Andy Moran                                      Ph. (503) 626 6616, x113
Galois Connections Inc.                              Fax. (503) 350 0833
12725 SW Millikan Way, Suite #290                  http://www.galois.com
Beaverton, OR 97005                                     moran at galois.com


More information about the Glasgow-haskell-users mailing list