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.
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.
The text was updated successfully, but these errors were encountered:
This test otherwise fails to build on windows/arm64 as of CL 364774
due to a warning (promoted to an error) about a mismatched dllexport
attribute. Fortunately, it seems not to need the forward-declared
function in this file anyway.
Trust: Bryan C. Mills <email@example.com>
Run-TryBot: Bryan C. Mills <firstname.lastname@example.org>
TryBot-Result: Go Bot <email@example.com>
Reviewed-by: Ian Lance Taylor <firstname.lastname@example.org>