Building GHC head with clang on Mavericks

Sven Panne svenpanne at gmail.com
Fri Jan 3 11:58:53 UTC 2014


2014/1/2 Carter Schonwald <carter.schonwald at gmail.com>:
> it looks like their work around is using ## rather than /**/

Well, actually lens is bypassing the problem by using cpphs, not the C
preprocessor. :-P OpenGLRaw is part of the Haskell Platform, and cpphs
is not, so I can't simply depend on it. (Licensing issues IIRC?)
"Don't do that" is not an option, either, at least not until the
binding is auto-generated. If I see this correctly, I really have to
do some preprocessor magic (slightly simplified output):

-----------------------------------------------------------------------------
svenpanne at svenpanne:~$ cat preprocess.hs
#define FOO(x) bla/**/x "x"
#define BAR(x) bla##x #x
FOO(baz)
BAR(boo)
svenpanne at svenpanne:~$ gcc -traditional -E -x c preprocess.hs
blabaz "baz"
bla##boo #boo
svenpanne at svenpanne:~$ gcc -E -x c preprocess.hs
bla baz "x"
blaboo "boo"
svenpanne at svenpanne:~$ clang -traditional -E -x c preprocess.hs
bla baz "x"
bla##boo #boo
svenpanne at svenpanne:~$ clang -E -x c preprocess.hs
bla baz "x"
blaboo "boo"
-----------------------------------------------------------------------------

If -traditional is not used, things are simple and consistent, and we
can simply use ## and #. Alas, -traditional *is* used, so we can't use
## and # with gcc an we are out of luck with clang. This really sucks,
and I consider the clang -traditional behavior a bug: How can you do
concatenation/stringification with clang -traditional? One can detect
clang via defined(__clang__) and the absence of -traditional via
defined(__STDC__), but this doesn't really help here.

Any suggestions? I am testing with a local clang 3.4 version (trunk
193323), but I am not sure if this matters.


More information about the ghc-devs mailing list