我创建了以下用于读取图像的C语言库:
typedef struct {
unsigned int height;
unsigned int width;
unsigned char* red; //length=height*width
unsigned char* green;
unsigned char* blue;
} Contents;
Contents readJPEGFile(const char* inFilename);
我找不到关于如何在Haskell中使用数组和结构体以及Foreign Function Interface的任何信息。我该如何继续才能使用我的库呢?
我尝试使用下面的示例作为基础:http://therning.org/magnus/archives/315,但是hsc文件被编译成了只包含上述C代码而没有其他内容的hs文件(当然它无法编译)。
c2hsc
工具,可以从 C 头文件中自动生成大部分的 hsc 文件。 - John Wiegley