Linux command
c2hs 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Generate Haskell bindings from C header
c2hs [header.h] [bindings.chs]
Specify include path
c2hs -C -I[/path/to/includes] [bindings.chs]
Pass preprocessor defines
c2hs -C -D[MACRO=value] [bindings.chs]
Specify output directory
c2hs -o [output_dir] [bindings.chs]
Show help
c2hs --help
说明
c2hs is a C to Haskell interface generator that simplifies creating FFI bindings to C libraries. It extracts interface information from C header files and generates Haskell code with foreign imports and correct type marshaling. The tool processes .chs files containing Haskell code with embedded hooks that reference C structures and functions.
参数
- -C _options_
- Pass options to C preprocessor (-I, -D, etc.)
- -o _directory_
- Output directory for generated files
- -c _compiler_
- Use specific C compiler
- --cppopts=_options_
- C preprocessor options
- -d _type_
- Dump internal information (trace, genbind, ctrav, chs)
- -k
- Keep intermediate files
- --help
- Show help
- --version
- Show version
FAQ
What is the c2hs command used for?
c2hs is a C to Haskell interface generator that simplifies creating FFI bindings to C libraries. It extracts interface information from C header files and generates Haskell code with foreign imports and correct type marshaling. The tool processes .chs files containing Haskell code with embedded hooks that reference C structures and functions.
How do I run a basic c2hs example?
Run `c2hs [header.h] [bindings.chs]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -C _options_ do in c2hs?
Pass options to C preprocessor (-I, -D, etc.)