golang/go

cmd/cgo: cgo "//export" usage missing crucial info

Open

#56,853 opened on 2022年11月19日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)Go (19,008 forks)batch import
DocumentationNeedsFixhelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (30d に merged PR はありません)

説明

What is the URL of the page with the issue?

https://pkg.go.dev/cmd/cgo

About "//export".

While the example code itself shows correct usage, the paragraph surrounding it doesn't say two things you should NOT do:

  1. Other "functional" comments in cgo allows beginning white spaces. Thus, for readability, one does (with a space between "//" and "#")
// #cgo pkg-config: ...

"//export" does not allow a space between. It is also extremely difficult to find out when the space should be deleted for this to work as intended. (A suitable warning if "// export ..." is used?)

  1. The other less important thing is trailing garbage/comments. Though a suitable error is emitted, it would be nice to be able to do have trailing comments like this:
//export MyRoutine // used by MyOtherProject
  1. It is also not clear whether the "//export MyRoutine" and the next line "func MyCoolRoutine ..." name must match. One might want to name routines by Go convention in Go code, but export as a different name following C code's naming conventions, for example?

What is your user agent?

Screenshot

What did you do?

What did you expect to see?

What did you see instead?

コントリビューターガイド