Subject:
|
Re: thread class for legOS
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Mon, 21 Jan 2002 01:34:56 GMT
|
Viewed:
|
1753 times
|
| |
![Post a public reply to this message](/news/icon-reply.gif) | |
On Mon, 21 Jan 2002, Ross Crawford wrote:
> > 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(...);
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 runWrapper(...)
Note that type-safe linkage isn't a problem since the C++ code is the one
that takes the address of the function, so different naming conventions
for functions is irrelevant. To be safe, you should always tag any C++
code that may be called from C as extern "C". On many platforms, you can
get away with it if you don't need to reference it by name in code
compiled by the other language (as in this case).
John A. Tamplin jat@jaet.org
770/436-5387 HOME 4116 Manson Ave
770/431-9459 FAX Smyrna, GA 30082-3723
|
|
Message has 1 Reply: ![](/news/x.gif) | | Re: thread class for legOS
|
| (...) Static DOES matter; it declares the method as being a "class" method, rather than a normal instance method. I believe there is no implicit 'this' parameter and therefore it can be treated like a normal function. Of course, it can't be linked (...) (22 years ago, 21-Jan-02, to lugnet.robotics.rcx.legos)
|
Message is in Reply To:
8 Messages in This Thread: ![thread class for legOS -Michael Wisse (18-Jan-02 to lugnet.robotics.rcx.legos)](/news/x.gif) ![](/news/46.gif) ![Re: thread class for legOS -Eric Swalens (18-Jan-02 to lugnet.robotics.rcx.legos)](/news/x.gif) ![](/news/46.gif) ![Re: thread class for legOS -Ross Crawford (21-Jan-02 to lugnet.robotics.rcx.legos)](/news/x.gif) ![](/news/246.gif) ![You are here](/news/here.gif) ![](/news/46.gif) ![Re: thread class for legOS -Michael Ash (21-Jan-02 to lugnet.robotics.rcx.legos)](/news/x.gif) ![](/news/46.gif) ![Re: thread class for legOS -John A. Tamplin (21-Jan-02 to lugnet.robotics.rcx.legos)](/news/x.gif) ![](/news/46.gif) ![Re: thread class for legOS -Michael Ash (22-Jan-02 to lugnet.robotics.rcx.legos)](/news/x.gif)
![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: thread class for legOS -Ross Crawford (21-Jan-02 to lugnet.robotics.rcx.legos)](/news/x.gif)
- 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
|
|
|
|