Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

taskSpawn a C++ function

401 views
Skip to first unread message

Gordon

unread,
Jun 26, 2003, 5:05:20 PM6/26/03
to
Dear all VxWorks experts,

I have seen people done this on the Web, but I got compiler error. Would
someone take a look what my problem is? All I am trying to do is to pass a
C++ function into the taskSpawn function within a class. I greatly
appreciate for any of your help.

//error messages from compiler.
..\testtask.cpp: In method `void A::init ()':
..\testtask.cpp:9: assuming & on `A::task'
..\testtask.cpp:9: converting from `void (A::*) (...)' to `int (*) (...)'
make: *** [testtask.o] Error 0x1

// the actual code
#include <taskLib.h>

class A
{
public:
void init()
{
taskSpawn("test", 100, 0, 10000, (FUNCPTR)A::task,
0,0,0,0,0,0,0,0,0,0);
}
void task(...) {}
};


Gordon


Wade Oram

unread,
Jun 26, 2003, 5:14:36 PM6/26/03
to
In message <3efb6013@shknews01>, Gordon <a@b.c> writes

The task member function requires a 'this' pointer to be supplied to it:

Try something like:

class A
{
void init()
{
taskSpawn("test", 100, 0, 10000, (FUNCPTR)A::taskStart,
(int)this,0,0,0,0,0,0,0,0,0);
}

static void taskStart(A* obj)
{
obj->task();
}

void task(...) {}
};

--
Wade Oram
Reply address valid for at least 1 calendar month from date of posting.

Gordon

unread,
Jun 27, 2003, 1:54:27 PM6/27/03
to
Thank you so much! It works!

Gordon

Wade Oram <news....@wtoram.co.uk> wrote in message news:<TZPvp6H8...@wtoram.co.uk>...

0 new messages