ROBOTC.net forums
http://www.robotc.net/forums/

RobotC 3.51 bug 10
http://www.robotc.net/forums/viewtopic.php?f=63&t=4931
Page 1 of 1

Author:  MHTS [ Sun Sep 30, 2012 2:23 am ]
Post subject:  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'
Code:
#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;
    Macro1(g_obj);
    nxtDisplayTextLine(1, "n1=%d", g_obj.n1);
   
    g_obj.n1 = 0;
    g_obj.t1 = 3;
    Macro2(g_obj);
    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.

Author:  Dick Swan [ Mon Oct 01, 2012 11:22 pm ]
Post subject:  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.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/