To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 2233
2232  |  2234
Subject: 
Re: thread class for legOS
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Mon, 21 Jan 2002 00:28:36 GMT
Viewed: 
1659 times
  
In lugnet.robotics.rcx.legos, Eric Swalens writes:
!!              m_Pid = execi(&Thread::runWrapper, 0, (char**)NULL,
m_Prio, m_Stack);

IRC, every method in C++ has an implicit parameter wich is the object itself;
that's why you can't cast it. Try the following (does someone have a nicer
solution?):

Put runWrapper() outside the class:

int runWrapper(int, char **th) {
((Thread*)th)->Run();
return 0;
}

in Start():

m_Pid = execi(runWrapper, 0, (char**)this, m_Prio, m_Stack);

Haven't done any C++ for a while, but IIRC you just need to declare runWrapper
as static, ie:

private:
static int runWrapper(...);

HTH

ROSCO



Message has 2 Replies:
  Re: thread class for legOS
 
(...) No, static doesn't matter but it is possible the calling conventions of C and C++ might be different (I don't know of a platform where that is the case for a an extern function), so you might need to specify C linkage, as in: extern "C" int (...) (22 years ago, 21-Jan-02, to lugnet.robotics.rcx.legos)
  Re: thread class for legOS
 
(...) In fact, neither of these suggestions will work with the code as it stands, because the runWrapper() function tries to call the Run() function, which is a non-static member function. You could pass a pointer to the class instance (this) in the (...) (22 years ago, 21-Jan-02, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  Re: thread class for legOS
 
(...) IRC, every method in C++ has an implicit parameter wich is the object itself; that's why you can't cast it. Try the following (does someone have a nicer solution?): Put runWrapper() outside the class: int runWrapper(int, char **th) { (...) (22 years ago, 18-Jan-02, to lugnet.robotics.rcx.legos)

8 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR