-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
用go编译win32的dll 怎么指定 _stdcall 的调用约束 #34466
Comments
我用这个库试了下,生成的armago_x64.h,没发现你说的参数有@n啊!
|
Would somebody like to translate this into English? Thanks. I tried Google Translate but it wasn't clear. |
He said that DLL compiled with go could not be used by other Win32 programs. |
Thanks. Closing as dup of #22192. |
The question is how to export WINAPI entry point without decoration. As i know, this can export an c entry point, exported entry name would be "SayHello":
And #32851 offered a way to export WINAPI by using cgo, exported entry name would be "_SayHello@0":
But i want the entry name to be "SayHello", how could i do? I have tried this answer 2 to add a comment in C code. The compile result is ok, but it didn't work(the entry name is still "_SayHello@0"):
Currently i am using CMAKE to build a dynamic library as intermediary. Adding a .def file to CmakeLists.txt works fine. @dzwvip 请问你找到解决方案了吗? |
ok
丁志伟
…------------------ 原始邮件 ------------------
发件人: wave <notifications@github.com>
发送时间: 2020年2月7日 18:46
收件人: golang/go <go@noreply.github.com>
抄送: dzwvip <dzwvip@qq.com>, Mention <mention@noreply.github.com>
主题: 回复:[golang/go] 用go编译win32的dll 怎么指定 _stdcall 的调用约束 (#34466)
The question is how to export WINAPI entry point without decoration.
As i know, this can export an c entry point, exported entry name would be "SayHello":
//export func SayHello(){ doSomething() }
And #32851 offered a way to export WINAPI by using cgo, exported entry name would be "_SayHello@0":
`
#include <stdlib.h>
extern void goSayHello(char *output, size_t outputSize, char *input);
__declspec(dllexport) void __stdcall SayHello() {
goSayHello();
}
`
But i want the entry name to be SayHello, how could i do?
I have tried https://inneka.com/programming/cpp/c-dll-export-decorated-mangled-names/ answer 2 to add a comment in C code. The compile result is ok, but it didn't work(the entry name is still "_SayHello@0"):
`C
#include <stdlib.h>
extern void goSayHello(char *output, size_t outputSize, char *input);
__declspec(dllexport) void __stdcall SayHello() {
#pragma comment(linker, "/EXPORT:SayHelo=_SayHello@0")
// or #pragma comment(linker, "/EXPORT:"FUNCTION"="FUNCDNAME)
goSayHello();
}
`
Currently i am using CMAKE to build a dynamic library as intermediary. Adding a .def file to CmakeLists.txt works fine.But i am still looking for a simple solution i could do this without an intermediary.
@dzwvip 请问你找到解决方案了吗?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
win32 程序调用 dll 默认的_stdcall方式, 用 go编译的dll 不能直接调用,我看 #32851 里面
https://github.com/code34/armago_x64 使用 C 函数 又包装了一下,可以使用了,但是又不想导出的函数名称后面 带有 @n ,该怎么解决 ??
What did you see instead?
The text was updated successfully, but these errors were encountered: