cmd/cgo: __declspec(dllexport) generated in header file while building shared-c lib on windows #56994
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
OS-Windows
Milestone
I use go1.18 building dll on windows.
The header file cgo generated will have __declspec(dllexport) in function declarations.
So before I publish lib to my colleague, I must change __declspec(dllexport) to __declspec(dllimport) handly.
Is there a method to generate __declspec(dllimport) directly? Or is it an issue?
in go, build command: go build -buildmode=c-shared -o libadd.go.dll .
//export Add
func Add(a, b int) int {
return a+b
}
in generated c header: libadd.go.h
extern __declspec(dllexport) int Add(int a, int b);
The text was updated successfully, but these errors were encountered: