[NXC][Compiler Error] Accessing data member in array

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

[NXC][Compiler Error] Accessing data member in array

Post by muntoo »

Here's a program which produces a compiler error:

Code: Select all

# Error: Error parsing expression: __ArrHelper__MM_opMM_ID_219_0.id
File "C:\Users\Gateway\Documents\TheUser\Programming\BricxCC\NXC\Memory Manager\.\MM_op.nxc" ; line 128
#   
#----------------------------------------------------------
# Error: Error parsing expression: __ArrHelper__MM_opMM_ID_219_1.id
File "C:\Users\Gateway\Documents\TheUser\Programming\BricxCC\NXC\Memory Manager\.\MM_op.nxc" ; line 129
#   
#----------------------------------------------------------
2 errors during compilation
On the following line:

Code: Select all

if(opands[0].id != tmp_opands[0].id)
Last edited by muntoo on 28 May 2011, 04:07, edited 1 time in total.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: [NXC][Compiler Error] Accessing data member in array

Post by afanofosc »

This defect seems to have been fixed since the following program compiles fine on my developer box.

Code: Select all

struct Foo {
  int id;
};

task main()
{
  Foo opands[1];
  Foo tmp_opands[1];

  if(opands[0].id != tmp_opands[0].id)
    Wait(SEC_1);
}
I dug around in SVN but I can't pinpoint when/where a change was made to fix this. Does the above code not compile for you?

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: [NXC][Compiler Error] Accessing data member in array

Post by muntoo »

That code sample you posted does...

This is my current version:

Code: Select all

Next Byte Codes Compiler version 1.2 (1.2.1.r4, built Tue Mar 15 15:38:58 CDT 2011)
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: [NXC][Compiler Error] Accessing data member in array

Post by afanofosc »

I can't work with your full memory manager code to try and track down this bug. You'll have to give me something simple like what I posted that demonstrates the problem. Maybe it has something to do with inline functions?

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: [NXC][Compiler Error] Accessing data member in array

Post by muntoo »

Here's a narrowed down version:

Code: Select all

struct MM_ID {
	unsigned int type;
	unsigned int len;
	unsigned long idx;
};

MM_ID MM_op(unsigned long op, MM_ID opands[], MM_ID out = MM_ID_NULL) {
	MM_ID tmp_opands[];

	if(opands[0].id != tmp_opands[0].id) {
		MM_ID tmp = tmp_opands[0];
	}

	return(out);
}

task main() {
	TextOut(0, 0, "Hello, world!", 0);
}
And here's the error:

Code: Select all

# Error: Error parsing expression: __ArrHelper__MM_opMM_ID_219_0.id
File "C:\Users\Gateway\Desktop\test.nxc" ; line 10
#   
#----------------------------------------------------------
# Error: Error parsing expression: __ArrHelper__MM_opMM_ID_219_1.id
File "C:\Users\Gateway\Desktop\test.nxc" ; line 10
#   
#----------------------------------------------------------
2 errors during compilation
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: [NXC][Compiler Error] Accessing data member in array

Post by afanofosc »

Dude. Your struct does not have a member called "id". It has one called "idx". If I rename the member in MM_ID to "id" rather than "idx" the code compiles fine.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: [NXC][Compiler Error] Accessing data member in array

Post by muntoo »

afanofosc wrote:Dude. Your struct does not have a member called "id". It has one called "idx". If I rename the member in MM_ID to "id" rather than "idx" the code compiles fine.

ARRGH! :) Thanks.

My excuse: The compiler errors are hard to decipher, though. Something like "# Error: Error parsing expression: .id member not found", maybe?

Maybe I should rename them all to .id because I find myself making this mistake constantly...
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 0 guests