Pages: 1 [2]   Go Down
Author Topic: Void -> how it returns values to the main programm  (Read 2836 times)
0 Members and 1 Guest are viewing this topic.
Wuppertal/Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 895
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes your code works
Code:
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:
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

Logged

Pages: 1 [2]   Go Up
Jump to: