头文件中结构体互相引用的问题
2017-01-25 18:08
218 查看
先上代码看下错误的例子:
编译提示:
./include/thread_pool.h:31:5: error: unknown type name ‘thpool_handle_t’
修改如下解决:
typedef struct _thread{ int id; /* friendly id */ pthread_t pthread; /* pointer to actual thread */ thpool_handle_t thpool_p; /* access to thpool */ } thread_t; /* Threadpool * threadpool has many threads, and he should to access each threads, threads pointer array to save all threads pointer */ typedef struct _thpool{ thread_t** threads; /* pointer to threads */ volatile int num_threads_alive; /* threads currently alive */ volatile int num_threads_working; /* threads currently working */ pthread_mutex_t thcount_lock; /* used for thread count etc */ jobqueue* jobqueue_p; /* pointer to the job queue */ } thpool_t, *thpool_handle_t;
编译提示:
./include/thread_pool.h:31:5: error: unknown type name ‘thpool_handle_t’
修改如下解决:
struct _thread;
struct _thpool;
typedef struct _thread thread_t;
typedef struct _thpool thpool_t, *thpool_handle_t;
typedef struct _thread{ int id; /* friendly id */ pthread_t pthread; /* pointer to actual thread */ thpool_handle_t thpool_p; /* access to thpool */ } thread_t; /* Threadpool * threadpool has many threads, and he should to access each threads, threads pointer array to save all threads pointer */ typedef struct _thpool{ thread_t** threads; /* pointer to threads */ volatile int num_threads_alive; /* threads currently alive */ volatile int num_threads_working; /* threads currently working */ pthread_mutex_t thcount_lock; /* used for thread count etc */ jobqueue* jobqueue_p; /* pointer to the job queue */ } thpool_t, *thpool_handle_t;
相关文章推荐
- 使用预声明解决结构体互相引用以及头文件内容互相包含的问题
- 使用预声明解决结构体互相引用以及头文件内容互相包含的问题[转]
- 使用预声明解决结构体互相引用以及头文件内容互相包含的问题
- 头文件互相引用的问题
- 关于OC头文件互相引用的问题(未完待续)
- 关于OC头文件互相引用的问题
- 两个不同的类相互引用的情况下头文件包含问题
- ASP.NET 2.0中母版页中引用文件路径的问题(收集)
- 15-奇怪的Js文件引用问题
- 利用HttpHandler处理自定义控件中需要引用大量js文件问题
- 母版页引用外部文件的路径问题
- 引用外部JS文件的问题
- 笔记:解决文件互相包含问题的小方法
- ASP.NET 2.0中母版页中引用文件路径的问题
- 模版页中引用文件路径的问题
- 使用Jbuilder引用外部jar包制作的jar文件,运行时的问题
- 利用HttpHandler处理自定义控件中需要引用大量js文件问题
- (转)模版页中引用文件路径的问题
- 解决头文件相互包含问题的方法----超前引用- -
- 模版页中引用文件路径的问题