From: "Ye Liu" <yliu@tibco.com>
To: pthreads-win32@sourceware.cygnus.com,
pthreads-win32-info@sourceware.cygnus.com
Subject: Using a class method as starting routine.
Date: Mon, 30 Jul 2001 13:50:00 -0000 [thread overview]
Message-ID: <3B65C795.A5680EC7@tibco.com> (raw)
Greets,
A rather dump question: how to use a class method as a starting routine
of pthread_create().
I have the following code:
/* create.h */
#ifndef _CREATE_H_
#define _CREATE_H_
#include <stdio.h>
#include "pthread.h"
class create
{
public:
create();
void *thread_routine(void *arg);
void start();
};
#endif
/* create.cpp */
#include "create.h"
void *create::thread_routine(void *arg)
{
printf("The thread is here\n");
return NULL;
}
void create::start()
{
pthread_t thread_id;
pthread_attr_t thread_attr;
pthread_create(&thread_id, &thread_attr, create::thread_routine, NULL);
}
create::create()
{
}
When I compiled it using VC6.0 (win32-pthread library of course), I got
create.cpp
C:\ye\work\vs\pthread_projects\create\create.cpp(14) : error C2664:
'pthread_create' : cannot convert parameter 3 from 'void *(void *)' to
'void *(__cdecl *)(void *)'
None of the functions with this name in scope match the target
type
Error executing cl.exe.
It seems that the compiler does not recognize thread_routine as a
address. Why does it happen? How to get around of it?
Thanks a lot!
--ye
--
Ye Liu
Tel(O) 650-846-5228
next reply other threads:[~2001-07-30 13:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-30 13:50 Ye Liu [this message]
2001-07-30 20:06 ` Wayne Isaacs
2001-07-31 12:09 ` Ye Liu
2001-07-31 2:11 ` Ales Pour
2001-07-31 7:25 Bossom, John
2001-08-01 1:39 Gardian, Milan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3B65C795.A5680EC7@tibco.com \
--to=yliu@tibco.com \
--cc=pthreads-win32-info@sourceware.cygnus.com \
--cc=pthreads-win32@sourceware.cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).