views:

117

answers:

1

I have a C header file which defines the following function:

void my_func(pthread_t tid);

This is defined by another function:

void my_func(pthread_t tid) {
...

When I compile, it says:

****.h:2: error: expected specifier-qualifier-list before ‘pthread_t’

Any ideas what I'm doing wrong?

+5  A: 

You need to #include <pthread.h> in the header file so that pthread_t is in scope for the my_func() prototype.

Without the #include the compiler does not recognize pthread_t as a type, but it needs a type before the argument.

The error expected specifier-qualifier-list before ‘pthread_t’ is saying just that. You need a type (specifier-qualifier-list) before a parameter (‘pthread_t’).

pmg