Description
Go version
go version go1.23.3 windows/amd64
Output of go env
in your module/workspace:
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\KangJi\AppData\Local\go-build
set GOENV=C:\Users\KangJi\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\KangJi\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\KangJi\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.23.3
set GODEBUG=
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\KangJi\AppData\Roaming\go\telemetry
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\KangJi\AppData\Local\Temp\go-build1436118867=/tmp/go-build -gno-record-gcc-switches
What did you do?
I fixed an issue where cgo-generated header files were not compatible with MSVC when using ISO C++ 17 or later. The headers only worked with ISO C++ 14 or earlier due to certain constructs that were deprecated or removed in newer C++ standards.
To reproduce the issue:
- Build a DLL using cgo to generate the corresponding header file.
- Try including the generated header in an MSVC project with C++ standard set to ISO C++ 17 or later (e.g., /std:c++17 or /std:c++20).
- Compilation fails due to incompatibility with newer C++ standards.
What did you see happen?
When compiling the cgo-generated header file in an MSVC project with ISO C++ 17 or later, the compiler produced errors due to the use of constructs that are no longer valid in newer C++ standards.
Example error messages:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2146: syntax error: missing ';' before identifier 'GoComplex64'
error C4430: missing t¥pe specifier - int assumed. Note: C++ does not support default-int
error C2146: syntax error: missing ';' before identifier 'GoComplex128'
What did you expect to see?
I expected the cgo-generated header file to be compatible with MSVC regardless of the C++ standard version being used. It should compile without errors in projects using ISO C++ 17, C++ 20, and later, just as it does with ISO C++ 14 or earlier.
The current output is incorrect because it prevents projects that use newer C++ standards from integrating with cgo-generated code. This issue limits compatibility and forces users to downgrade their C++ standard or modify the generated header manually, which is not an ideal solution. The header should be generated in a way that ensures compatibility with modern C++ versions.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status