View unanswered posts | View active topics It is currently Mon Aug 10, 2020 3:43 pm

Reply to topic  [ 2 posts ] 
RobotC 3.51 bug 10 
Author Message
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post RobotC 3.51 bug 10
When compiled the following code, the compiler gave me the error on the call to Macro2:
**Error**:Calling procedure 'Func1'. '&' Invalid parameter for reference variable. Parameter: 'short & n'. Expression: '(g_obj).n1'. Type: 'short'
#define Macro1(p)   Func1((p).t1, p.n1)
#define Macro2(p)   Func1((p).t1, (p).n1)

typedef struct
    int t1;
    int n1;
} OBJ;

OBJ g_obj;

void Func1(int t1, int &n)
    n = t1 + 120;

task main()
    Func1(1, g_obj.n1);
    nxtDisplayTextLine(0, "n1=%d", g_obj.n1);
    g_obj.n1 = 0;
    g_obj.t1 = 2;
    nxtDisplayTextLine(1, "n1=%d", g_obj.n1);
    g_obj.n1 = 0;
    g_obj.t1 = 3;
    nxtDisplayTextLine(2, "n1=%d", g_obj.n1);

The only difference between Macro1 and Macro2 is a pair of parenthesis. Apparently, RobotC doesn't like it if the parameter is passed by reference.

Sun Sep 30, 2012 2:23 am

Joined: Fri Feb 09, 2007 9:21 am
Posts: 616
Post Re: RobotC 3.51 bug 10
I think this is a variant of a previously reported bug that has been fixed but not yet released. I tried to reproduce and got no compiler error. Visually checking the compiled assembly language everything looks fine.

Mon Oct 01, 2012 11:22 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

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.