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 / 1718
1717  |  1719
Subject: 
Re: execi and C++
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Sun, 18 Feb 2001 23:55:39 GMT
Viewed: 
1554 times
  
Bernardo Dal Seno <piu1759@cdc8g5.cdc.polimi.it> writes:

"Ciaran Jessup" <ciaranjessup@myrealbox.com> writes:

Hi all, sorry if this is a rediculously trivial problem, but I'm having some
problems with execi on legos0.2.5 , I can't seem to get g++ to compile when
I use it, I pass it a 'correct' function.....like so :

int controlThread(int argc, char **argv) {   ....blla....blah..blah }
defined earlier in file....

execi(&controlThread, 0, NULL, 2, DEFAULT_STACK_SIZE);

And it throws an error, saying :

ANSI C++ forbids implicit conversion from `void *' in argument passing


In C you should call execi() like this:

  execi(controlThread, 0, NULL, 2, DEFAULT_STACK_SIZE);  /* Removed `&' */

since a function is like an array name: it is an address.  Probably the same
applies to C++.

I've spoken too fast.  Re-reading the error message I saw the real problem.
"controlThread" or "&controlThread" are the same.  You should add a cast:

execi(&controlThread, 0, (char **)NULL, 2, DEFAULT_STACK_SIZE);

NULL is defined mem.h as "((void*)0)" and that causes problem with C++ due
to the stricter type checking.  The right definition for NULL in C++ is
(according to B. Stroustrup):

  const int NULL = 0;

legOS included should be corrected (any maintainer listening? :-).


bye
Bernardo



Message is in Reply To:
  Re: execi and C++
 
(...) In C you should call execi() like this: execi(controlThread, 0, NULL, 2, DEFAULT_STACK_SIZE); /* Removed `&' */ since a function is like an array name: it is an address. Probably the same applies to C++. bye Bernardo (24 years ago, 18-Feb-01, to lugnet.robotics.rcx.legos)

3 Messages in This Thread:

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

Custom Search

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