如何修复由race标志引起的cgo错误?

huangapple go评论135阅读模式
英文:

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

https://go.dev/src/runtime/cgo/gcc_libinit_windows.c

答案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

huangapple
  • 本文由 发表于 2023年1月10日 16:55:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75067559.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定