英文:
How to fix cgo error caused by race flag?
问题
如何解决这个问题?
STDERR: # runtime/cgo
gcc_libinit_windows.c: 在函数‘_cgo_beginthread’中:
gcc_libinit_windows.c:136:27: 错误:隐式声明函数‘_beginthread’;你是不是指‘_cgo_beginthread’?[-Werror=implicit-function-declaration]
136 | thandle = _beginthread(func, 0, arg);
| ^~~~~~~~~~~~
| _cgo_beginthread
cc1: 所有警告都被当作错误处理
make[1]: *** [Makefile:15: unit] 错误 2
https://go.dev/src/runtime/cgo/gcc_libinit_windows.c
英文:
How can I fix this?
STDERR: # runtime/cgo
gcc_libinit_windows.c: In function ‘_cgo_beginthread’:
gcc_libinit_windows.c:136:27: error: implicit declaration of function ‘_beginthread’; did you mean ‘_cgo_beginthread’? [-Werror=implicit-function-declaration]
136 | thandle = _beginthread(func, 0, arg);
| ^~~~~~~~~~~~
| _cgo_beginthread
cc1: all warnings being treated as errors
make[1]: *** [Makefile:15: unit] Error 2
答案1
得分: 3
原来是与Cygwin编译器有关的问题,切换到Mingw(https://github.com/niXman/mingw-builds-binaries/releases)后,一切都正常了。
英文:
It turned out that it was some issue with cygwin compiler, after switching to mingw (https://github.com/niXman/mingw-builds-binaries/releases) everything works fine.
答案2
得分: 0
请查看文件 go1.19.1\src\runtime\cgo\libcgo_windows.h
// 调用 _beginthread,在失败时中止。
void _cgo_beginthread(void (*func)(void*), void* arg);
所以...
在 gcc_libinit_windows.c
中删除函数 _cgo_beginthread
将修复此问题。
英文:
see the file go1.19.1\src\runtime\cgo\libcgo_windows.h
// Call _beginthread, aborting on failure.
void _cgo_beginthread(void (*func)(void*), void* arg);
so...
delete function _cgo_beginthread
in gcc_libinit_windows.c
will fix it
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论