Parens to avoid CPP macros in foreign imports
Ian Lynagh
igloo at earth.li
Mon Apr 5 15:08:55 EDT 2004
Hi all,
curses (and I gather this is a reasonably common thing in C libraries)
allows some functions to be implemented as macros, but provides
functions as well so you can do things like pass function pointers
around. Enclosing the function name in parentheses hides it from cpp.
With things as they are, cpp expanding macros can cause foreign imports
to not generate code that gcc accepts. Is there a reason why something
like this can't be done instead?
diff -u -r1.103 PprAbsC.lhs
--- ghc/compiler/absCSyn/PprAbsC.lhs 9 Oct 2003 11:58:41 -0000 1.103
+++ ghc/compiler/absCSyn/PprAbsC.lhs 5 Apr 2004 12:49:56 -0000
@@ -960,7 +960,7 @@
if null non_void_results
then empty
else text "%r = ",
- lparen, fun_name, lparen,
+ lparen, lparen, fun_name, rparen, lparen,
hcat (punctuate comma ccall_fun_args),
text "));"
])
It seems to work for me on the first case I happened across.
Thanks
Ian
More information about the Cvs-ghc
mailing list