golang/go

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

Open

#56.853 aperta il 19 nov 2022

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)Go (19.008 fork)batch import
DocumentationNeedsFixhelp wanted

Metriche repository

Star
 (133.883 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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?

Guida contributor