hsc2hs和c2hs之间的区别? [英] Difference between hsc2hs and c2hs?

查看:220
本文介绍了hsc2hs和c2hs之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hsc2hs和c2hs有什么区别?



我知道hsc2hs是一个预处理器,但它究竟干什么?



c2hs可以从C代码创建Haskell模块,但是我需要hsc2hs吗?

解决方案

它们都具有相同的功能:可以更容易地编写FFI绑定。如果您选择使用c2hs,则不需要了解hsc2hs;他们是独立的。 C2hs更强大,但也更复杂:Edward Z. Yang在他的有许多
Haskell预处理器;你应该使用哪一个
?表达
以上层次结构的简短(并且有些是
不准确)的方式是您进一步下跌
,您的
编写的样板文件越少,文档$ b $越多b你必须阅读;因此,我听到了
的建议,即hsc2hs是您应该使用
的小型FFI项目,而c2hs
更适用于较大的



c2hs支持hsc2hs
的事物不会: b
$ b


  • 自动生成基于C
    头文件的内容

  • 函数调用的半自动编组和

  • 指针类型和层次结构的转换转换为Haskell类型。



What is the difference between hsc2hs and c2hs?

I know what hsc2hs is a preprocessor but what does it exactly do?

And c2hs can make Haskell modules from C-code, but do I need hsc2hs for this?

解决方案

They both have the same function: make it easier to write FFI bindings. You don't need to know about hsc2hs if you chose to use c2hs; they are independent. C2hs is more powerful, but also more complicated: Edward Z. Yang illustrates this point with a nice diagram in his c2hs tutorial:

When should I use c2hs? There are many Haskell pre-processors; which one should you use? A short (and somewhat inaccurate) way to characterize the above hierarchy is the further down you go, the less boilerplate you have to write and the more documentation you have to read; I have thus heard advice that hsc2hs is what you should use for small FFI projects, while c2hs is more appropriate for the larger ones.

Things that c2hs supports that hsc2hs does not:

  • Automatic generation of foreign import based on the contents of the C header file
  • Semi-automatic marshalling to and from function calls, and
  • Translation of pointer types and hierarchies into Haskell types.

这篇关于hsc2hs和c2hs之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆