Go Down

Topic: Void -> how it returns values to the main programm (Read 2 times) previous topic - next topic

wayoda

Yes your code works
Code: [Select]

void myProc (int& a, int& b) {
 a = 2;
 b = 7;
}

int myA = 0;  //Belt AND braces.
int myB = 0;

void setup () {
 myProc (myA, myB);
 Serial.begin (9600);
 Serial.println (myA);
 Serial.println (myB);
}

void loop () {
}


but this one doesn't
Code: [Select]

int myA = 0;  //Belt AND braces.
int myB = 0;

void setup () {
 myProc (myA, myB);
 Serial.begin (9600);
 Serial.println (myA);
 Serial.println (myB);
}

void loop () {
}

void myProc (int& a, int& b) {
 a = 2;
 b = 7;
}

The IDE does not generate a prototype for functions that use arguments with reference parameters.

see:
http://code.google.com/p/arduino/issues/detail?id=205
(please ignore that the OP of the google-code issue got the headline wrong)

Eberhard


Go Up