Generating Function Prototypes
reid at reid-consulting-uk.ltd.uk
Thu Jul 4 17:32:36 EDT 2002
> Alistair wrote [snip]
>> ps I still think we're better off removing header files completely
>> and having the Haskell type completely determine the calling
>> convention employed. But since I'm not getting any takers on that,
>> I'll settle for pinning down the spec as tightly as possible.
> [snip] Perhaps I'm missing something here, but in that case how on
> earth is the poor user to find out if the Haskell type really
> corresponds to the C type, before the program coredumps?
> I see there is a problem here in that no such check can be carried
> out when the compilation is not done via C. Would it be possible
> for the compiler in such a case to spit out a C file which
> typechecks if and only if the Haskell and C prototypes match, and
> ask gcc to typecheck it? You could even use this approach in all
> cases, then C code compiled from Haskell would never need to include
> user-supplied header files.
Yes, I believe something along these lines could be done.
C compilers spit out information about the calling convention in a
variety of cunning encodings: .stab debugging entries, warning
messages, error messages, etc. It's just a question of figuring out
More information about the FFI