As you know static member functions do not have a this pointer. soinstead, what shall i do?

for example ... consider I want to call

Code: ( text )

1. pthread_create(&thID,NULL,classA::B, (void *) this);

An off topic but common question. You must pass an extern "C" linkagefunction to C library functions that expect a function pointer as one oftheir parameters.

You *must* not pass a class member function and *should* not pass astatic member function.

I didn't know about the static member function. Why is that (some
portability issue on their representation I presume)?

There is no guarantee that any C++ function will have the same linkage
as a C function. In practice most non-member functions do, but the
compiler is free to issue a diagnostic when one is passed to a function
expecting an extern "C" function pointer.

You can use template along the following pattern (using intermediary
class or not, using richer templatization ...):

This isn't strictly correct (but it will probably work) as function
templates can not have extern "C" linkage.

>As you know static member functions do not have a this pointer. soinstead, what shall i do?

>for example ... consider I want to call

>Code: ( text )

> 1. pthread_create(&thID,NULL,classA::B, (void *) this);

An off topic but common question. You must pass an extern "C" linkage
function to C library functions that expect a function pointer as one of
their parameters.

You *must* not pass a class member function and *should* not pass a
static member function.

I didn't know about the static member function. Why is that (some
portability issue on their representation I presume)?

There is no guarantee that any C++ function will have the same linkage
as a C function. In practice most non-member functions do, but the
compiler is free to issue a diagnostic when one is passed to a function
expecting an extern "C" function pointer.

Not "free to", required to. Linkage is part of type, and
passing a function with "C++" linkage to pthread_create is just
as much an error as passing one which takes an int instead of a
pointer, or which returns void, instead of void*.

With regards to Michael's code, I don't think a template
instantiation can have C linkage, so the code is illegal.

You can use template along the following pattern (using intermediary
class or not, using richer templatization ...):

This isn't strictly correct (but it will probably work) as function
templates can not have extern "C" linkage.

In which case, a good compiler, in strictly conforming mode,
should refuse to compile the code. (Note that both g++ and VC++
get this wrong.)

>>I didn't know about the static member function. Why is that (someportability issue on their representation I presume)?

>There is no guarantee that any C++ function will have the same linkageas a C function. In practice most non-member functions do, but thecompiler is free to issue a diagnostic when one is passed to a functionexpecting an extern "C" function pointer.

Not "free to", required to. Linkage is part of type, and
passing a function with "C++" linkage to pthread_create is just
as much an error as passing one which takes an int instead of a
pointer, or which returns void, instead of void*.

Agreed, but many (most?) don't. Sun CC is the only compiler I know that
does object.

>Not "free to", required to. Linkage is part of type, andpassing a function with "C++" linkage to pthread_create is justas much an error as passing one which takes an int instead of apointer, or which returns void, instead of void*.

Agreed, but many (most?) don't. Sun CC is the only compiler I know thatdoes object.

Of course the EDG front-end in strict mode rejects it as well, though
not all EDG-based compilers do. The front-end offers the
--implicit_extern_c_type_conversion and
--no_implicit_extern_c_type_conversion options to control this, but it
is up to the compiler writer whether they are made available to the
user (of course, the conversion cannot work if the compiler uses
incompatible calling conventions for C and C++ functions).

As you know static member functions do not have a this pointer. so
instead, what shall i do?

for example ... consider I want to call

Code: ( text )

1.
pthread_create(&thID,NULL,classA::B, (void *) this);

and it is called in an static method so instead of this what can I
put??

If you can you're much better off using Boost::threads for this.

It depends. The conception of Boost::threads is far from
perfect, and it's all to easy to accidentally get a detached
thread due to an unexpected exception. The advantages of
Boost::threads limit themselves to: 1) they've already wrapped
the system API, so you don't have to learn both Windows and
Posix, and worry about system dependant code yourself, and 2) in
cases where you want to view the new thread as a functional
object, with its own totally independant lifetime,
Boost::threads has already handled the copying and the
synchronization issues at thread start up for you. (2 is almost
always the case for detached threads, rarely however for
joinable threads.)