From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7854 invoked by alias); 14 Dec 2007 13:47:35 -0000 Received: (qmail 7839 invoked by uid 22791); 14 Dec 2007 13:47:33 -0000 X-Spam-Check-By: sourceware.org Received: from relay2.uni-heidelberg.de (HELO relay2.uni-heidelberg.de) (129.206.210.211) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 14 Dec 2007 13:47:22 +0000 Received: from ix.urz.uni-heidelberg.de (cyrus1.urz.uni-heidelberg.de [129.206.119.235]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id lBEDj792010911; Fri, 14 Dec 2007 14:45:07 +0100 Received: from [127.0.0.1] (guest4-1-02.gh.uni-heidelberg.de [147.142.160.206]) by ix.urz.uni-heidelberg.de (8.8.8/8.8.8) with ESMTP id OAA29524018; Fri, 14 Dec 2007 14:47:16 +0100 Message-ID: <47628963.9030001@tatramed.sk> Date: Fri, 14 Dec 2007 13:49:00 -0000 From: Peter Slacik User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071128 SeaMonkey/1.1.7 MIME-Version: 1.0 To: satish CC: pthreads-win32 Subject: Re: error C2678 and C2440 References: <57a6149b0712140110o229cf003h196271eaeb8b7c76@mail.gmail.com> In-Reply-To: <57a6149b0712140110o229cf003h196271eaeb8b7c76@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2007/txt/msg00054.txt.bz2 Hi, (shortened) satish wrote: > Hi, > I am porting my multi threading(using pthread) Linux project to > windows. The compiler is MS VC++ 2005. > > The project compilation is almost done but I am getting few errors > related to pthread. > > A.:- Have a look on following code, > ---------------------------------------------------------------- > typedef struct { > pthread_t id; > } THREADLIST; > > THREADLIST threads[MAXTHREADS]; > > 1283 pthread_t self = pthread_self(); > 1286 if (threads[i].flags != THREAD_UNUSED && threads[i].id == self) ---------------------------------------------------------------- > > The error, I am getting is, > > 1>main.cpp(1286) : error C2678: binary '==' : no operator found which > takes a left-hand operand of type 'pthread_t' (or there is no > acceptable conversion) > 1> c:\program files\microsoft visual studio > 8\vc\platformsdk\include\guiddef.h(192): could be 'int operator > ==(const GUID &,const GUID &)' > 1> while trying to match the argument list '(pthread_t, pthread_t)' > > IIRC you've to use int pthread_equal(pthread_t thread1, pthread_t thread2) for the comparison. Because pthread_t is defined as: typedef struct { void * p; /* Pointer to actual object */ unsigned int x; /* Extra information - reuse count etc */ } ptw32_handle_t; typedef ptw32_handle_t pthread_t; > B.:- Another piece of code on which I am getting error is, > ---------------------------------------------------------------- > 52 int ret; > 53 ret = pthread_self(); > ---------------------------------------------------------------- > Here, it gives error like, > > 1>main.cpp(53) : error C2440: '=' : cannot convert from 'pthread_t' to 'int' > > Because of pthread_self()'s return value definition: pthread_t pthread_self (void); Already in your previous example, you've used 1283 pthread_t self = pthread_self(); This is the way to go. > Can you please tell me the reason behind these errors? > I will be very thankful to you. > > Regards > Satish > With regards Peter PS: I'm resending this, my original email was not plain text, sorry.