cvs commit: fptools/libraries/base/Text/Regex Posix.hsc
Malcolm.Wallace at cs.york.ac.uk
Fri Jan 28 10:59:02 EST 2005
Ross Paterson <ross at soi.city.ac.uk> writes:
> > Modified files:
> > libraries/base/Text/Regex Posix.hsc
> > Log:
> > Fix regex.h include stuff; Ross and Malcolm might want to look at the
> > new comment
> The "hacky solution" is the only way offered by the FFI spec to specify
> the include for foreign imports. I gave up on that limitation some
> time ago, and made the Hugs build system extract the -#include options
> from GHC OPTIONS pragmas. I think it would be better to have a less
> compiler-specific equivalent, though. An INCLUDE pragma?
The "correct" solution, blessed by the FFI addendum, is for all
such platform-specific configuration to be done outside Haskell,
incorporated into a single .h file that is named in the foreign import.
For instance, here for regexes, the simplest solution is to prepend
to libraries/base/include/regex/regex.h the following few lines:
#if HAVE_REGEX_H && HAVE_REGCOMP
... and then a simple
foreign import ccall unsafe "regex/regex.h regexec" :: ....
is correct for all environments.
More information about the Cvs-libraries