Void (and other) Pointers
Page 1 of 1

Author:  amcerbu [ Tue Oct 23, 2012 7:24 pm ]
Post subject:  Void (and other) Pointers

I was very happy to hear that the RobotC developers at Carnegie Mellon added pointers in the new release. I was wondering, however, to what extent pointers were implemented. Are there void pointers? Are there pointers to structs? Are there pointers to pointers? Is there any "malloc"-type function? I remember reading last year that there was no support for dynamic memory allocation (probably to prevent memory leaks -- don't know how one would fix something like that on an NXT), but has this changed? Thanks.

Author:  MHTS [ Wed Oct 24, 2012 3:29 am ]
Post subject:  Re: Void (and other) Pointers

Yes to all your questions except for malloc/free. There is still no dynamic memory allocation support in RobotC. In other words, there is no heap.

Author:  amcerbu [ Wed Oct 31, 2012 8:10 pm ]
Post subject:  Re: Void (and other) Pointers

How about function pointers? Is this sort of code legal?

void my_function(int x)
    // Do something with x

task main()
    void (*function_pointer)(int);
    function_pointer = &my_function;


    return 0;

Author:  MHTS [ Wed Oct 31, 2012 9:38 pm ]
Post subject:  Re: Void (and other) Pointers

I wish but no, there is no function pointer support in RobotC.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group