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

How can I pass a char ** variable thought a taskSpawn?

337 views
Skip to first unread message

Falessi D.

unread,
Jun 3, 2004, 4:25:38 PM6/3/04
to
Hi,
I don't understand how to pass a variable like "char **pippo" to
another task thought the taskSpawn argument?

Thanks
D. Falessi

Joe Durusau

unread,
Jun 3, 2004, 8:28:28 PM6/3/04
to

taskSpawn takes only integer values. In many procesors, the
size of a pointer is the same as the size of an integer. Therefore,
if you pass in the right value, the task in question could cast it
or use it in any desired way. (A nasty programming habit, I know,
but if you really need to do it, ......)

Speaking only for myself,

Joe Durusau

Michael R. Kesti

unread,
Jun 3, 2004, 7:45:23 PM6/3/04
to
Joe Durusau wrote:

The usual problem with using casts this way is that it can lead to
portability problems. If one has no expectations of portability,
and in embedded systems one may genuinely not, then one may have no
problem.

If you expect portability or just wish to better express what is
happening, a better solution is the use of unions. For example, one
could declare pippo thus:

union {
char **ppc;
int i;
} pippo;

Then, when using pippo as a pointer to pointer to char, express it as
pippo.ppc. When using pippo as an integer, express it as pippo.i. The
compilers will now figure out how to allocate pippo such that it will
work regardless of whether the size of a pointer is the same as the size
of an integer.

--
========================================================================
Michael Kesti | "And like, one and one don't make
| two, one and one make one."
mke...@gv.net | - The Who, Bargain

VijayaRaghavan

unread,
Jun 4, 2004, 3:18:08 AM6/4/04
to VxWorks Users Group List

Hi,
This can be done in another simple way too. U can typecast address
of a p2p as a integer "(int )pippo" while passing as a argument. After
receiving into the function U can do typecast it back ... & Use it as U
wish.
ie.
char **pippo;

taskSpawn
(
name, /* name of new task (stored at pStackBase) */
priority, /* priority of new task */
options, /* task option word */
stackSize, /* size (bytes) of stack needed plus name */
entryPt, /* entry point of new task */
(int)pippo , /* 1st of 10 req'd task args to pass to func */
.......
);


----
In entry point of the function .
entryPt ( int p2p)
{
char **pippo = (Char **)p2p;
// u got it back here!

}

WITH REGARDS,
rVr


Michael R. Kesti wrote:

Confidentiality Notice

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mail...@wipro.com immediately
and destroy all copies of this message and any attachments.

0 new messages