From e31607662b352b2fb4fadbae02ad13a32676dc7e Mon Sep 17 00:00:00 2001 From: "rick.chan" Date: Wed, 6 Jan 2021 13:35:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Example.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: rick.chan --- .../Go/Basic/Build_and_Use_Go_Packages_as_C_Libraries.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Software/Development/Language/Go/Basic/Build_and_Use_Go_Packages_as_C_Libraries.md b/Software/Development/Language/Go/Basic/Build_and_Use_Go_Packages_as_C_Libraries.md index 0a8a9df..26c6616 100644 --- a/Software/Development/Language/Go/Basic/Build_and_Use_Go_Packages_as_C_Libraries.md +++ b/Software/Development/Language/Go/Basic/Build_and_Use_Go_Packages_as_C_Libraries.md @@ -2,7 +2,7 @@ CGO is an official builtin feature of Go, it enables the creation of Go packages that reference to C libraries. But it isn’t just that, it is achievable in the opposite direction, too. It enables creation of C libraries from Go packages so that C code can reference to Go, which is mind-blowing. -CGO 不但可以使 Go 包访问 C 库,还可以通过 Go 包创建 C 库。 +CGO 不但可以使 Go 包访问 C 库,还可以通过 Go 包创建 C 库,进而使 C/C++ 程序可调用 Go 语言程序。 ## 1.How to @@ -40,6 +40,8 @@ To export a Go function as a C symbol: * 在要导出的函数使用 **//export FuncName** 注释; * 不能使用 Go struct、Go interface、Go arra、以及可变参数。 +## 2.Example + ```go package main