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: pthread_t definiton and STL...


The "implement.h" is purposely separated from "pthread.h" to obscure the
implementation from the users.

pthread_t is defined to be a pointer to a structure that is not
defined for the users. It is only defined for the implementation.

This isolates the user's from changes to the implementation.

The reason pthread_t is defined as
	typedef struct pthread_t_ *	pthread_t;

is to permit strong type checking of the pointer without defining the
actual struct, itself. The C compiler allows you to have a pointer
to an undefined type so long as you do not dereference the pointer
in your code.

Including "implement.h" into pthread.h breaks these gains.

What error are you getting from the system?

-----Original Message-----
From: Ales Pour [mailto:pour@princip.cz]
Sent: January 11, 2001 9:05 AM
Cc: pthreads-win32@sources.redhat.com
Subject: pthread_t definiton and STL...



Hello,
I'm having a tiny trouble with pthread_t type definition since I've been
using this _great_ library.
The following code doesn't compile with VC5 (SP3) using SGI's STL:

#include <vector>

using namespace std;

#include "pthread.h"

int main()
{
	vector<pthread_t> _v;

	return 0;
}

VC complains:

...\include\stl\stl_construct.h(58) : error C2027: use of undefined type
'pthread_t_'

I fix this problem by adding '#include "implement.h"' to pthread.h ...
Now I wonder if there's better way to avoid this error.
Thank you a lot.

Ales Pour

--------------
Ales Pour
Princip a.s.
Czech Republic

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