[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

pthread has error on Etch



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear all,
I wrote following code :
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
int g1=0;
int g2=0;
void *task1(int *counter);
//void task2(int *counter);
void cleanup(int counter1,int counter2);
int main(int argc,char *argv[])
{
        pthread_t thr1,thr2;

        if ( pthread_create(&thr1,NULL,task1,(void*)g1))
        {
                perror("pthread_create : task1");
                exit(EXIT_FAILURE);
        }

/*      if ((ret = pthread_create(&thr2,NULL,task2,(void *)&g2)))
        {
                perror("pthread_create : task2");
                exit(EXIT_FAILURE);
        }*/


//      pthread_join(thr2,NULL);
        pthread_join(thr1,NULL);

        cleanup(g1,g2);
        exit(EXIT_SUCCESS);
}//end of main program
void *task1(int *counter)
{
        while(*counter < 5 ){
                printf("task1 count: %d\n",*counter);
                (*counter)++;
        }//end of while
void cleanup(int counter1,int counter2)
{
        printf("Total iterations: %d\n",counter1+counter2);
}//end of cleanup function



But i receive following error:


mohsen@debian:~/test/learning/pthread$ make
gcc -c -Wall test.c -lpthread
In file included from test.c:3:
/usr/include/pthread.h:285: error: conflicting types for ‘pthread_t’
/usr/include/bits/pthreadtypes.h:152: error: previous declaration of
‘pthread_t’ was here
/usr/include/pthread.h:286: error: conflicting types for ‘pthread_attr_t’
/usr/include/bits/pthreadtypes.h:54: error: previous declaration of
‘pthread_attr_t’ was here
/usr/include/pthread.h:287: error: conflicting types for ‘pthread_key_t’
/usr/include/bits/pthreadtypes.h:82: error: previous declaration of
‘pthread_key_t’ was here
/usr/include/pthread.h:289: error: conflicting types for
‘pthread_mutexattr_t’
/usr/include/bits/pthreadtypes.h:102: error: previous declaration of
‘pthread_mutexattr_t’ was here
/usr/include/pthread.h:290: error: conflicting types for ‘pthread_mutex_t’
/usr/include/bits/pthreadtypes.h:95: error: previous declaration of
‘pthread_mutex_t’ was here
/usr/include/pthread.h:291: error: conflicting types for
‘pthread_condattr_t’
/usr/include/bits/pthreadtypes.h:79: error: previous declaration of
‘pthread_condattr_t’ was here
/usr/include/pthread.h:292: error: conflicting types for ‘pthread_cond_t’
/usr/include/bits/pthreadtypes.h:72: error: previous declaration of
‘pthread_cond_t’ was here
test.c: In function ‘main’:
test.c:13: warning: passing argument 3 of ‘pthread_create’ from
incompatible pointer type
test.c:11: warning: unused variable ‘thr2’
test.c: In function ‘task1’:
test.c:38: warning: control reaches end of non-void function
make: *** [main.o] Error 1
mohsen@debian:~/test/learning/pthread$

My distro is Debian Etch.
kernel is 2.6.18
I have post it to pthread mailing list,They said me that i reinstall
libc6-dev package,i reinstalled it,But i see given errors.
Please help me....
Yours,Mohsen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGBgWG/ZBAvBh9bHIRAnjXAJ4vE52ozyz8AqKANNBucCn1jhtOTgCfUpZu
v/ZfoJ4M8hRF2PTK9+MbgIk=
=N16l
-----END PGP SIGNATURE-----



Reply to: