View unanswered posts | View active topics It is currently Sun Jul 12, 2020 4:34 pm

Reply to topic  [ 2 posts ] 
Issue using Function Prototypes 
Author Message

Joined: Wed Feb 04, 2015 7:04 am
Posts: 7
Post Issue using Function Prototypes
Hi forum,

I have been having issues with using function prototypes which pass parameters. The code does not compile, as RobotC doesn't recognise the prototype as one.
The code below shows this:

// Prototypes
int test(int);
int test_b(void);

// Variables
int q,w;

task main()

int test(int x)

int test_b(void)

The issue is that int test(int) is not been read as a prototype at the top of the file, and therefore is displaying errors. However the function int test_b, which has no parameters passed to it, works as expected (without errors). Now I understand that in this simple piece of code, I could just move the functions around so that the compiler knows they exist when they are called; however my larger more complex code utilises many functions and this cannot be done.
As a side note the code above compiles and builds fine in any normal C compiler.

Is this another known limitation with RobotC?

Kind Regards,
Thomas Barnett (MEng)

Fri Mar 27, 2015 9:22 am
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: Issue using Function Prototypes
When you create the prototypes, you have to make sure you not only create the parameter's data type but also its name. Try changing your prototype to the code listed below, recompile, and let us know if you run into any other issues as we are more than happy to help.

int test(int x);

Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.

Mon Mar 30, 2015 1:58 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.