2

私は次のようなものを持っています:

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

私が試した2番目の方法:

void* vp_threads = threads; //Error: initializer element is not constant

私はこれをしなければならないので...(以下を参照してください!)

void some_func()
{
   add_head(vp_threads, ...)
...
}

void add_head(void* x, ...)
{ ... }

(追記: main() や初期化関数はありません。これは core.c ファイルのようなもので、.h にあるすべての関数を実装しています)

なぜこれがうまくいかないのか、void* を自分の構造を指すようにしようとしているだけです。これの何が問題なのですか?

4

1 に答える 1

1

やってみる

vp_threads = threads;

メイン(または初期化関数)

ステートメントをグローバル スコープに入れることはできません。あなたのステートメントvp_threads = threads; は、どこかの関数内に存在する必要があります

于 2012-04-23T21:42:36.537 に答える