Go Down

Topic: sample code in reference does not compile ( IDE 022) (Read 1 time) previous topic - next topic

butch


Here is the link:  http://www.arduino.cc/en/Reference/FunctionDeclaration

Here is the compile error: [font=Verdana]function_2_demo:6: error: function definition does not declare parameters[/font]

Here is the code that does not compile:

void setup(){
  Serial.begin(9600);
}

void loop{
  int i = 2;
  int j = 3;
  int k;

  k = myMultiplyFunction(i, j); // k now contains 6
  Serial.println(k);
  delay(500);
}

int myMultiplyFunction(int x, int y){
  int result;
  result = x * y;
  return result;
}

retrolefty

Looks like a typro/error in the reference, missing () after loop.

Quote
Here is the code that does not compile:

void setup(){
  Serial.begin(9600);
}

void loop(){
  int i = 2;
  int j = 3;
  int k;

  k = myMultiplyFunction(i, j); // k now contains 6
  Serial.println(k);
  delay(500);
}

int myMultiplyFunction(int x, int y){
  int result;
  result = x * y;
  return result;
}

butch

Thanks to Retrolefty

That is indeed correct.  Now how do we get the web page corrected?

mellis


Go Up