【发布时间】:2020-02-20 18:30:24
【问题描述】:
我正在使用 cgo 并看到 this 关于从 go 运行 c++ 的帖子:
我想在 Go 中使用 [此功能]。我将使用C接口
// foo.h #ifdef __cplusplus extern "C" { #endif typedef void* Foo; Foo FooInit(void); void FooFree(Foo); void FooBar(Foo); #ifdef __cplusplus } #endif
我这样做了,但是如何将字符串作为参数传递给 C++ 函数?我尝试传递 rune[],但没有成功。
【问题讨论】:
-
我假设您的意思是像 C 中那样以 nul 结尾的字符串,而不是某些 C++ 字符串类。如果是这样,请参阅github.com/golang/go/wiki/cgo#go-strings-and-c-strings
-
我引用了您引用的参考文献来扩展您的问题。希望对您有所帮助。