View unanswered posts | View active topics It is currently Fri Oct 24, 2014 7:18 am






Reply to topic  [ 4 posts ] 
Void (and other) Pointers 
Author Message
Novice

Joined: Sun Oct 21, 2012 10:01 pm
Posts: 76
Post 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.


Tue Oct 23, 2012 7:24 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post 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.


Wed Oct 24, 2012 3:29 am
Profile
Novice

Joined: Sun Oct 21, 2012 10:01 pm
Posts: 76
Post Re: Void (and other) Pointers
How about function pointers? Is this sort of code legal?

Code:
void my_function(int x)
{
    // Do something with x
    return;
}

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

    (*function_pointer)(5);

    return 0;
}


Wed Oct 31, 2012 8:10 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Void (and other) Pointers
I wish but no, there is no function pointer support in RobotC.


Wed Oct 31, 2012 9:38 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.