-
Notifications
You must be signed in to change notification settings - Fork 18k
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/go: c-shared header does not compile on Visual Studio #36233
Comments
And I'm curious that there is no lib file, how is the msvc link the code? |
I have the same problem, did you find for a solution? |
Change https://go.dev/cl/379474 mentions this issue: |
__SIZE_TYPE__ is a GCC type which has been superseded by size_t -define in stddef.h- since ISO C99. cmd/cgo already uses size_t in many places, but still generates several files using __SIZE_TYPES__, most notably the _cgo_export.h. This change replaces all __SIZE_TYPES__ occurrences with size_t. Updates #36233 Change-Id: Id8a99b5d7763caab9333eab9b585e78249a37415 Reviewed-on: https://go-review.googlesource.com/c/go/+/379474 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Change https://go.dev/cl/397134 mentions this issue: |
MSVC can link Go DLL's compiled by MinGW using different tricks. The one I use the most is this one: # 1. Build MinGW DLL.
go build -buildmode=c-shared -o foo.dll . # Generate MinGW DLL
# 2. Generate a def file out of the DLL.
gendef foo.dll
# 3. Generate the MSVC import library.
dlltool --input-def foo.def --output-lib foo.lib
# 4. Compile the C file using MSVC with the import library previously generated.
# There is no need for foo.dll to be present when compiling C,
# but it must be available when running the resulting binary.
cl.exe main.c foo.lib |
The last line can you explain? I have no c file I'm only using go. How can I do this? |
If you are only using Go why do you need Visual Studio? |
What version of Go are you using (
go version
)?go1.13.5 windows/386
Does this issue reproduce with the latest release?
Yes
What did you do?
go build -buildmode=c-shared -o client.dll test.go
this command generated a client.h header file, it has some code like this:
typedef signed char GoInt8;
typedef unsigned char GoUint8;
typedef short GoInt16;
typedef unsigned short GoUint16;
typedef int GoInt32;
typedef unsigned int GoUint32;
typedef long long GoInt64;
typedef unsigned long long GoUint64;
typedef GoInt32 GoInt;
typedef GoUint32 GoUint;
typedef SIZE_TYPE GoUintptr;
typedef float GoFloat32;
typedef double GoFloat64;
typedef float _Complex GoComplex64;
typedef double _Complex GoComplex128;
What did you expect to see?
Hope it can be compiled in VC
What did you see instead?
But this file can not compile in Visual Studio, the error is :
Error 28 error C2061: syntax error : identifier 'GoUintptr'
Error 30 error C2061: syntax error : identifier 'GoComplex64'
Error 32 error C2061: syntax error : identifier 'GoComplex128'
The text was updated successfully, but these errors were encountered: