Go Down

Topic: Void -> how it returns values to the main programm (Read 3307 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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy