"In file included" when using passing byte in function?

I have a little snippet of code which writes to an I2C sensor of mine. However, I noticed an odd behavior. If I pass the address of the byte through the function, it requires an "in file".

Function:

int readRange(byte Sensor) {
  Wire.beginTransmission(Sensor);
  Wire.write(0x00);  // Open register for sending command
  Wire.write(0x51);  // Send ranging command
  Wire.endTransmission();

  delay(100);

  Wire.beginTransmission(Sensor);
  Wire.write(0x02);  // Open register for reading data
  Wire.endTransmission();

  Wire.requestFrom(Sensor,2);
  while (Wire.available() < 2) ;
  byte highByte = Wire.read();
  byte lowByte = Wire.read();

  return ((highByte << 8) + lowByte);
}

Console output:

In file included from srf_code.cpp:1:0:
/usr/share/arduino/libraries/Wire/Wire.h: In function 'int readRange(byte)':
/usr/share/arduino/libraries/Wire/Wire.h:58:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)
/usr/share/arduino/libraries/Wire/Wire.h:56:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)

However, if I don't pass the byte in the beginning (the way I had it in an earlier revision of the code), and just have the sensor address in-line, it doesn't include anything.

Function definition:

int readRange()

Why does it do this? Is this a bad programming practice? It seems to work fine when I upload it.

The function readRange() takes one argument, of type byte. That argument is passed to the requestFrom() method of the Wire instance. Wire is an instance of the class TwoWire.

The messages are telling you that no version of the requestFrom() method takes a byte as the first argument while the second argument is an int.

Either change the first argument to an int, changing the readRange() signature or change the second argument to a byte, too. Use a variable, of type byte/uint8_8 or cast the constant.

Thanks, that was it. I'll test out the new code later when I have the sensor, but at least it compiles without any messages now.