some NXC beginner questions

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
tobasco666
Posts: 2
Joined: 13 Oct 2010, 09:05

some NXC beginner questions

Post by tobasco666 »

Hi,
Usaually I'm working with high-level-languages, therfore I run into some pitfalls when I start to work with NXC (BricxCC 3.3):

When I try to declare a multi-dim-array with initialization I get Errors: Variable name expected, ";" expected

Code: Select all

int matrix[][] = {{1, 2, 3}, {4, 5, 6}};
When I try to create a function which returns an int array I get Errors: ";" expected, ";" expected, ";" expected

Code: Select all

int foo[] (){
  int bar[] = {1,2,3};
  return bar;
}
It would be great if someone could enlighten me :roll:

salute
Thomas
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: some NXC beginner questions

Post by afanofosc »

This code compiles fine with the latest official release of BricxCC and NBC/NXC.

Code: Select all

task main()
{
  int matrix[][] = {{1, 2, 3}, {4, 5, 6}};
  NumOut(0, LCD_LINE1, matrix[0][0]);
  Wait(SEC_5);
}
NXC currently does not support returning arrays of any kind from a user-defined function. Can you post a request to the NXC wish list thread if you would like to see this supported in a future release?

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

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