我有一个 C 头文件,它定义了以下函数:
void my_func(pthread_t tid);
这是由另一个函数定义的:
void my_func(pthread_t tid) {
...
当我编译时,它说:
****.h:2: error: expected specifier-qualifier-list before ‘pthread_t’
知道我做错了什么吗?
最佳答案
您需要#include <pthread.h>
在头文件中这样 pthread_t
属于 my_func()
的范围原型(prototype)。
没有#include
编译器无法识别pthread_t
作为一种类型,但它需要在参数之前有一个类型。
错误expected specifier-qualifier-list before ‘pthread_t’
就是这么说的。在参数(‘pthread_t’)之前需要一个类型(说明符限定符列表)。
关于c - 将 pthread_t 传递给函数时出现奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1698375/