Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/cgo: can't build with both inline C function define and Go function export #10982
can't build with both inline C function define andGo function export
got compile error:
cgo writes the inline C functions both in cgo.cgo2.c and _cgo_export.h
This is working as intended and it's documented. http://golang.org/cmd/cgo/#hdr-C_references_to_Go Using //export in a file places a restriction on the preamble: since it is copied into two different C output files, it must not contain any definitions, only declarations. Definitions must be placed in preambles in other files, or in C source files. A trick is that if you only declare functions in the cgo preamble, then you can label the function static.