This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: I'v got nuts, please help me with the g++ option


Try replacing the 
>pthread_t * thread;

with 
pthread_t thread;

and creating thread with:
pthread_create (&thread,NULL,threadproc,NULL);
pthread_join (&thread, NULL);

You need to look into memory allocation for the variable thread!!
Suggestion to read Richard Stevens' book on IPC.

Sar

--- Jianhua xu <joshua_60030@yahoo.com> wrote:
>Dear Mr./Madam,
>   I installed a Redhat9(shrike), g++ 3.2.2 , libgcc
>3.2.2, got Segmentation fault when using
>pthread_create function. the try program is very
>simply, please tell me which header file and library i
>should use when linking.
>
>following is my program
>
>#include <>
>#include <pthread.h>
>void * threadproc(void*p)
>{
>printf("dd\n");
>}
>int main(int argc,char** argv)
>{
>pthread_t * thread;
>pthread_create(thread,NULL,threadproc,NULL);
>pthread_join(*thread,NULL);
>return 1;
>}
>
>
>Thanks & Regards,
>
>joshua
>
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! SiteBuilder - Free, easy-to-use web site design software
>http://sitebuilder.yahoo.com

_____________________________________________________________
Powered by a short email address ... http://www.k.st


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]