This is the mail archive of the pthreads-win32@sources.redhat.com mailing list for the pthreas-win32 project.


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

RE: C++ typedef problem(?)


Answers:

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.


-----Original Message-----
From: Dennis Foreman [mailto:dforeman@stny.rr.com]
Sent: March 10, 2001 9:45 AM
To: Pthread-List
Subject: C++ typedef problem(?)


I recently had an occasion to use:

#include pthread.h
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?


regards,
D. J. Foreman
website: http://WWW.CS.Binghamton.EDU/~foreman


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