0

我正在尝试在我的应用程序中实现线程池系统。我希望每个线程都有一个指向我正在使用的线程池结构的指针。所以,基本上我有两个类似于以下的结构:

typedef struct thread_pool {
    /* some fields here */
    single_thread **tds;
} thread_pool_t;

typedef struct single_thread {
    /* some fields here */
    thread_pool_t *tp;
} single_thread_t;

与声明顺序无关,编译器会报错。我解决了在第一个结构之前声明第二个结构,但将其声明为空。现在我没有收到任何错误,但我总是收到以下警告:

serv_inc/thrhandler.h:23:16: warning: useless storage class specifier in empty declaration [enabled by default]

有没有办法避免这个警告并达到同样的结果?我做错了吗,有没有更有效的解决方案来解决这个问题?

4

1 回答 1

6

这对我有用:

typedef struct thread_pool thread_pool_t;
typedef struct single_thread single_thread_t;

struct thread_pool
{
    single_thread_t **tds;
};

struct single_thread
{
    thread_pool_t *tp;
};
于 2013-06-12T15:34:11.953 回答