From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: ffc1e,37831c95f62a1c14,start X-Google-Attributes: gidffc1e,public X-Google-Thread: 10ba33,37831c95f62a1c14,start X-Google-Attributes: gid10ba33,public X-Google-Thread: fee84,37831c95f62a1c14,start X-Google-Attributes: gidfee84,public From: magrasjc@texas.net Subject: c++ & pthreads: oil and water ? Date: 1997/11/12 Message-ID: <3469D2DB.58D695B9@texas.net>#1/1 X-Deja-AN: 288953692 To: rwhite@pobox.com, kris@snet.net Organization: Texas Networking, Inc. Newsgroups: comp.programming.threads,gnu.g++.help,comp.unix.osf.osf1 Note:There is a crosspost to news:comp.lang.c++.moderated Greetings, How does a program integrate Posix threads and C++? It would be a major impasse for one to preclude the use of the other.... but C++ is allergic to void * which pthread_create() uses for 2 arguments. rwhite@pobox.com wrote: (It doesn't seem to work in DEC UNIX 3.2 /g++ 2.7.2.2 .... pthread_create call: conversion from `void *' to non-scalar type `CMA_T_HANDLE' requested first line of ThreadEntry::Invoke's definition header : parse error before `::' typedef void * (*start_func)(void *); template class ThreadEntry { T * Object; void * (T::* Member)(void); static void * Invoke(ThreadEntry *); public: ThreadEntry(T * Target, void *(T::* func)(void)): Object(Target), Member(func) { pthread_t threadID; pthread_create(&threadID,NULL,Invoke,(void *)this); RegisterThread(threadID); }; }; template void * ThreadEntry::Invoke(ThreadEntry * Target) { void * retval = Target->(Object->*Member)(); delete Target; return retval; } NOTE: I call a function called "RegisterThread". This is *not* found in any library ... you must define it. -- Unix Software Engineer looking for C++/UNIX/Motif/Perl/Tk/Flex Software Engineering position **NOW**. Currently in Austin at (512) 672-5778/magrasjc@texas.net. have Answering machine.