提问人:Gxdung 提问时间:10/28/2023 更新时间:10/28/2023 访问量:29
在 CentOS 7 上使用“go build”时,“错误:重新定义”struct timespec“”
'error: redefinition of ‘struct timespec’' when using the 'go build' on CentOS 7
问:
在 CentOS 7 上使用“go build”命令时,我收到错误“错误:重新定义'struct timespec'”,但 Windows 11 没问题。
GCC 版本:软件包 gcc-4.8.5-44.el7.x86_64 GoLang 版本:go 1.21.3 linux/amd64
以下是详细信息:
[root@iZuf67zcjjcc3tn3l8lcpfZ AFurCon-API-V2]# go build
# runtime/cgo
In file included from /usr/include/pthread.h:29:0,
from gcc_libinit.c:7:
/usr/include/bits/types/struct_timespec.h:9:8: error: redefinition of ‘struct timespec’
struct timespec
^
In file included from /usr/include/sched.h:32:0,
from /usr/include/pthread.h:23,
from gcc_libinit.c:7:
/usr/include/time.h:120:8: note: originally defined here
struct timespec
^
gcc_libinit.c:16:1: error: braces around scalar initializer [-Werror]
static pthread_cond_t runtime_init_cond = PTHREAD_COND_INITIALIZER;
^
gcc_libinit.c:16:1: error: (near initialization for ‘runtime_init_cond.__data.__lock’) [-Werror]
gcc_libinit.c:16:1: error: braces around scalar initializer [-Werror]
gcc_libinit.c:16:1: error: (near initialization for ‘runtime_init_cond.__data.__futex’) [-Werror]
gcc_libinit.c:16:1: error: braces around scalar initializer [-Werror]
gcc_libinit.c:16:1: error: (near initialization for ‘runtime_init_cond.__data.__total_seq’) [-Werror]
gcc_libinit.c:16:1: error: excess elements in scalar initializer [-Werror]
gcc_libinit.c:16:1: error: (near initialization for ‘runtime_init_cond.__data.__total_seq’) [-Werror]
gcc_libinit.c:16:1: error: braces around scalar initializer [-Werror]
gcc_libinit.c:16:1: error: (near initialization for ‘runtime_init_cond.__data.__wakeup_seq’) [-Werror]
gcc_libinit.c:16:1: error: excess elements in scalar initializer [-Werror]
gcc_libinit.c:16:1: error: (near initialization for ‘runtime_init_cond.__data.__wakeup_seq’) [-Werror]
gcc_libinit.c:16:1: error: braces around scalar initializer [-Werror]
gcc_libinit.c:16:1: error: (near initialization for ‘runtime_init_cond.__data.__nwaiters’) [-Werror]
gcc_libinit.c:16:1: error: excess elements in scalar initializer [-Werror]
gcc_libinit.c:16:1: error: (near initialization for ‘runtime_init_cond.__data.__nwaiters’) [-Werror]
In file included from gcc_libinit.c:7:0:
gcc_libinit.c:17:42: error: ‘__PTHREAD_SPINS’ undeclared here (not in a function)
static pthread_mutex_t runtime_init_mu = PTHREAD_MUTEX_INITIALIZER;
^
gcc_libinit.c:17:1: error: braces around scalar initializer [-Werror]
static pthread_mutex_t runtime_init_mu = PTHREAD_MUTEX_INITIALIZER;
^
gcc_libinit.c:17:1: error: (near initialization for ‘runtime_init_mu.__data.__elision’) [-Werror]
gcc_libinit.c:17:1: error: excess elements in scalar initializer [-Werror]
gcc_libinit.c:17:1: error: (near initialization for ‘runtime_init_mu.__data.__elision’) [-Werror]
gcc_libinit.c: In function ‘_cgo_try_pthread_create’:
gcc_libinit.c:133:3: error: passing argument 1 of ‘nanosleep’ from incompatible pointer type [-Werror]
nanosleep(&ts, nil);
^
In file included from /usr/include/pthread.h:24:0,
from gcc_libinit.c:7:
/usr/include/time.h:334:12: note: expected ‘const struct timespec *’ but argument is of type ‘struct timespec *’
extern int nanosleep (const struct timespec *__requested_time,
^
cc1: all warnings being treated as errors
答: 暂无答案
评论