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: How to get value's type 'const char * MyFunc' from dll export #21110

Closed
llgoer opened this issue Jul 21, 2017 · 1 comment

Comments

@llgoer
Copy link

commented Jul 21, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.8.3 windows/386

What operating system and processor architecture are you using (go env)?

set GOARCH=386
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=386
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Go\projects
set GORACE=
set GOROOT=D:\Go\bin\go
set GOTOOLDIR=D:\Go\bin\go\pkg\tool\windows_386
set GCCGO=gccgo
set GO386=
set CC=gcc
set GOGCCFLAGS=-m32 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2

What did you do?

The dll export function like const char * MyFunc()
the C include file like this

extern "C" __declspec(dllexport) const char * MyFunc()
{
//....
}

When I use python,I can do like this

dll =  CDLL('MyDLL')
MyFunc = loadFun('MyFunc',c_char_p)
result = MyFunc()

the vals return the value I want.
When I use go

MyDLL := syscall.MustLoadDLL("MyDLL")
MyFunc := DllNLPIR.MustFindProc("MyFunc")
result, _, _ := MyFunc.Call()
fmt.Println(result)
fmt.Println(reflect.TypeOf(result))

What did you expect to see?

the MyFunc return const char * MyFunc

What did you see instead?

830541584
uintptr

@bradfitz

This comment has been minimized.

Copy link
Member

commented Jul 21, 2017

For questions about Go, see https://golang.org/wiki/Questions.

@bradfitz bradfitz closed this Jul 21, 2017

@mikioh mikioh changed the title How to get value's type 'const char * MyFunc' from dll export cmd/cgo: How to get value's type 'const char * MyFunc' from dll export Aug 2, 2017

@golang golang locked and limited conversation to collaborators Aug 2, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.