Home > Net >  How to fix cgo error caused by race flag?
How to fix cgo error caused by race flag?

Time:01-10

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

CodePudding user response:

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

CodePudding user response:

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 find.

  • Related