Pointers 全局void*,使其指针指向结构指针

Pointers 全局void*,使其指针指向结构指针,pointers,void,Pointers,Void,我有点像: struct list{ struct list **next, **prev; } 全球宣言: struct list *threads = &((struct list){&threads, &threads}); void* vp_threads; /Error here: previous declaration of 'vp_threads' was here vp_threads = threads; //Error here

我有点像:

struct list{
   struct list **next, **prev;
}
全球宣言:

struct list *threads = &((struct list){&threads, &threads});
void* vp_threads;      /Error here:  previous declaration of 'vp_threads' was here
vp_threads = threads;  //Error here: conflicting types for vp_threads
我尝试的第二种方式:

void* vp_threads = threads; //Error: initializer element is not constant
我必须这样做,因为。。。(见下文!)

(PS:这里没有main()或初始化函数,这是核心的.c文件,实现了.h中的所有函数)

为什么这不起作用,我只是想制造空虚,指向我的结构。这有什么问题吗?

试试看

vp_threads = threads;
主(或初始化函数)


不能将语句放入全局范围。您的语句
vp\u threads=threads必须存在于函数的某个地方

我试过了,它给了我错误“initializer元素不是常量”,这是核心.c文件,只是函数的实现。没有主函数或任何初始化函数,这就是我想要全局函数的原因。我应该在问题中告诉你有一个名为core_init()的函数并调用它,但我不能这么做。。。这被同一文件中的其他函数使用!没关系,一旦初始化,所有的东西都可以使用它
vp_threads = threads;