Description
In #46502, we observed build errors on windows/arm64
due to redeclaration warnings about mismatched dllexport
attributes.
That was ultimately resolved by CL 327309, for which the commit message states:
This [forward-declaring C-exported Go functions] is not something user code will ever do, so no need to make it work in cgo.
However, we know from #19837 that user code does sometimes need to forward-declare C-exported Go functions, in order to pass the C wrappers as callbacks to other C functions. Absent a fix for that issue, the workaround applied in CL 327309 at least ought to be documented.
The only restriction currently documented for forward-declarations in the C preamble (https://pkg.go.dev/cmd/cgo@master#hdr-C_references_to_Go) is:
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. If a file contains both definitions and declarations, then the two output files will produce duplicate symbols and the linker will fail. To avoid this, definitions must be placed in preambles in other files, or in C source files.
It does not say anything about avoiding forward-declarations, nor about a need to forward-declare functions exported by Go with any particular attributes or keywords.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status