Function was not declared in this scope error

Hello,

I am new to Platformio and trying to include VL53L1X_Arduino_Library and ran into issues:

https://github.com/sparkfun/SparkFun_VL53L1X_Arduino_Library

I am getting this error message:
‘_distanceMode’ was not declared in this scope

Based on the my search on forums I should declared this function on top but i am clueless…?
I also addded #include <Arduino.h> to SparkFun_VL53L1X_Arduino_Library.h file.

This is main.cpp

#include <Arduino.h>
#include <Wire.h>
#include "SparkFun_VL53L1X_Arduino_Library.h"

VL53L1X distanceSensor;

void setup(void)
{
  Wire.begin();

  Serial.begin(9600);
  Serial.println("VL53L1X Qwiic Test");

  if (distanceSensor.begin() == false)
    Serial.println("Sensor offline!");

}

void loop(void)
{
  distanceSensor.startMeasurement(); //Write configuration bytes to initiate measurement

  //Poll for completion of measurement. Takes 40-50ms.
  while (distanceSensor.newDataReady() == false)
    delay(5);

  int distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor

  Serial.print("Distance(mm): ");
  Serial.print(distance);

  float distanceInches = distance * 0.0393701;
  float distanceFeet = distanceInches / 12.0;

  Serial.print("\tDistance(ft): ");
  Serial.print(distanceFeet, 2);

  Serial.println();
}

Thanks all

The error is cause by an actual error in the library

The version that PIO downloads you has the line:

  private:
    //Variables
    TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware
    uint8_t _deviceAddress; //Keeps track of I2C address. setI2CAddress changes this.
	_distanceMode = 0;

The last declaration is not syntactically valid. The newest git version has it fixed since 1 day. (see here)

So you can just tell PIO to grab the newest github version by going to your platformio.ini and adding the line

lib_deps = https://github.com/sparkfun/SparkFun_VL53L1X_Arduino_Library

(Delete any previous lib_deps directives which download the old version of the library)

For me your code then compiles fine

avr-objcopy -O ihex -R .eeprom .pioenvs\uno\firmware.elf .pioenvs\uno\firmware.hex
avr-size --mcu=atmega328p -C -d .pioenvs\uno\firmware.elf
AVR Memory Usage
----------------
Device: atmega328p

Program:    6180 bytes (18.9% Full)
(.text + .data + .bootloader)

Data:        480 bytes (23.4% Full)
(.data + .bss + .noinit)


 [SUCCESS] Took 9.17 seconds 

Thanks a million for prompt reply Maxgerhardt. Your are right and I followed your advise and added lib_deps and that updated the library.

Thanks again :grinning: