Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: missing documentation about "dllexport" redeclaration problem on windows/arm64 #49721

bcmills opened this issue Nov 22, 2021 · 1 comment
Documentation NeedsFix


Copy link

@bcmills bcmills commented Nov 22, 2021

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 ( 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.

Copy link

@gopherbot gopherbot commented Nov 22, 2021

Change mentions this issue: misc/cgo/test: remove unnecessary forward declaration

gopherbot pushed a commit that referenced this issue Nov 22, 2021
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.

Updates #49633
Updates #49721

Change-Id: Ia4698b85077d0718a55d2cc667a7950f1d8e50ab
Trust: Bryan C. Mills <>
Run-TryBot: Bryan C. Mills <>
TryBot-Result: Go Bot <>
Reviewed-by: Ian Lance Taylor <>
@bcmills bcmills added the NeedsFix label Nov 22, 2021
@bcmills bcmills added this to the Backlog milestone Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Documentation NeedsFix
None yet

No branches or pull requests

2 participants