This is the mail archive of the
mailing list for the pthreas-win32 project.
RE: C++ typedef problem(?)
- To: "'foreman at binghamton dot edu'" <foreman at binghamton dot edu>, Pthread-List <pthreads-win32 at sourceware dot cygnus dot com>
- Subject: RE: C++ typedef problem(?)
- From: "Bossom, John" <John dot Bossom at Cognos dot COM>
- Date: Mon, 12 Mar 2001 08:53:13 -0500
1) pthread.h doesn't include implementation.h on purpose. It is purposely
broken into two pieces to isolate USERS of the pthreads library from
the implementation of the pthreads library. i.e. The C compiler allows
declarations of pointers to undefined types so long as you do NOT
dereference the pointers...
typedef struct pthread_t * pthread_t;
typedef struct pthread_mutex_t * pthread_mutex_t;
I orginally did this instead of
typedef void * pthread_t;
typedef void * pthread_mutex_t;
so that there is still some strong(er) type checking...
i.e.) Using just void * as the base types would illegally allow
you to pass a pthread_t where a pthread_mutex_t is expected.
My original typedefs would not.
2) You shouldn't see any problems so long as you do not reference
anything in implementation.h. Stick to the interface as
defined in pthread.h.
From: Dennis Foreman [mailto:email@example.com]
Sent: March 10, 2001 9:45 AM
Subject: C++ typedef problem(?)
I recently had an occasion to use:
list<pthread_mutex_t *> x;
Where the list datatype comes from LEDA, which supposedly supports almost
anything as a type for the list class.
I got a syntax error from MSVC++ 5.0 saying that pthread_mutex_t_ (note the
ending "_") was an undefined type. I found a typedef for it in
implementation.h, so I included it too and the error went away. I am using a
pretty old version of the library (1999) because it has been very stable.
The questions are:
1. why didn't pthread.h include the implementation.h file itself?
2. will doing this cause me any other problems?
D. J. Foreman