
Joe Fredette ha scritto:
You know, I hear theres this brilliant program for compiling C code -- gcd? ccg? gcc, yah gcc... Anyone tried it?
In all seriousness though, why do you need to compile c with ghc? I'm curious, it seems a bit pointless...
It's for a possible extension I'm planning for Cabal. The idea is to add support for "configuration features". A configuration feature is similar to a "configuration flag", but with some important differences. data Feature = Bool | String A feature block: Feature HaveURandom action: execute include-dirs: ... c-sources: features/urandom.c -- other possible properties, as listed in -- "Build information chapter", excluding `buildable` and -- `other-modules` -- The `action` property can have values `compile` (default`) -- or `execute` This means that I'm testing for a feature named "HaveURandom", and the testing requires to compile/build and then execute some code. In this case there is only a C source file that needs to be compiled; this is the reason why I have asked if GHC supports compilation for C source files only, and the creation of an executable. Here I'm asking Cabal to execute the generated program. If the executable returns 0, then HaveURandom will have value `Feature True`; if it returns 1, then HaveURandom will have value `Feature False`. If the executable write something on stdout, then HaveURandom will have value `Feature string`. If compilation fails, HaveURandom will have value `Feature False`. If `action` property is "compile", then a successful compilation will result in HaveURandom having a value of `Feature True`. Regards Manlio