|
Ralph,
The second parameter to the task is a pointer to an array of pointers.
Those pointers (under DOS and other OSes) normally point to parameters on
the command line (string data).
However, there is no reason to not use them for other data types. So, you
can pass argc=1 and argv as &ptr_to_function; or argv as &ptr_to_structure.
Notice here that I am using '&' prior to the pointer... this equals **
(pointer to a pointer) Better example follows:
struct temp_struct {
int return;
};
int task(int argc, char** argv) {
struct temp_struct* pTemp = (temp_struct*)(*argv);
pTemp->return = 100;
}
int main(int argc, char** argv) {
struct temp_struct temp;
struct temp_struct* pTemp = &temp;
execi(&task, ..., 1, &pTemp, ...);
}
(I don't know the exact parameters for execi... so in the above example
argc=1 and argv = &pTemp)
I hope this helps.
// Joe
"Ralph Clark" <ralph.clark@ntlworld.com> wrote in message
news:H2J53w.4tw@lugnet.com...
> More specifically, how can you pass by reference to a thread?? I thought a
> thread could only take chracter arguments in an array?
> Thanks
>
> "Ralph Clark" <ralph.clark@ntlworld.com> wrote in message
> news:H2HwuD.L6L@lugnet.com...
> > Hi. Do we have pass by reference in the current version of legOS?
> >
> > If we don't, I'd be very grateful if anyone could give me a simple example
> > of how to do the same thing in C using pointers and whatever.
> >
> >
>
>
|
|
Message is in Reply To:
| | Re: Pass by reference
|
| More specifically, how can you pass by reference to a thread?? I thought a thread could only take chracter arguments in an array? Thanks "Ralph Clark" <ralph.clark@ntlworld.com> wrote in message news:H2HwuD.L6L@lugnet.com... (...) (22 years ago, 16-Sep-02, to lugnet.robotics.rcx.legos)
|
3 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|