mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 00:43:26 +08:00
04.4.2.md
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#3.9 与其它语言进行交互
|
||||
#3.9.1 与 C 进行交互
|
||||
##3.9.1 与 C 进行交互
|
||||
工具 cgo 提供了对 FFI(外部函数接口)的支持,能够使用 Go 代码安全地调用 C 语言库,你可以访问 cgo 文档主页:[http://golang.org/cmd/cgo](http://golang.org/cmd/cgo)。cgo 会替代 Go 编译器来产生可以组合在同一个包中的 Go 和 C 代码。在实际开发中一般使用 cgo 创建单独的 C 代码包。
|
||||
|
||||
如果你想要在你的 Go 程序中使用 cgo,则必须在单独的一行使用 `import "C"` 来导入,一般来说你可能还需要 `import "unsafe"`。
|
||||
|
Reference in New Issue
Block a user