How to remove cc1plus.exe: some warnings being treated as errors

hi everyone, I am facing some problems while working on a project
i am trying to use the position of gyro (using GY6050.h library) to rotate the servo motors. Down below is the following code.
for head transmitter.

/* 
 * Acceleration- Transmitter mit Wemos D1 mini pro
 */

#include <Wire.h>
#include <GY6050.h>
#include <ESP8266WiFi.h>

const char *ssid = "ESP32 AP";
const char *password = "";
// Use WiFiClient class to create TCP connections
WiFiClient client;
const char * host = "192.168.2.13";
const int httpPort = 80;

// Set your Static IP address
IPAddress local_IP(192, 168, 4, 14);
IPAddress gateway(192, 168, 4, 1);
IPAddress subnet(255, 255, 0, 0);
IPAddress primaryDNS(8, 8, 8, 8);   //optional
IPAddress secondaryDNS(8, 8, 4, 4); //optional


GY6050 gyro(0x68);         // Create Gyro object with "0x68" as I2C addres (most likely the address of your MPU6050)
int GyroX, GyroY, GyroZ;
int servoX1, servoX2, servoX3;
float posXsmoothed, posYsmoothed, posZsmoothed;
float posXold, posYold, posZold;
int16_t ax, ay, az ;

//Servo servoX; Servo servoY; Servo servoZ;
int posX = 90;  //10-170
int posY = 60;  //0-180
int posZ = 90;  //60-120
int posact = 90;


void setup() {
  Serial.begin(115200);
  delay(10);
  
  //Wire.begin(4,5); // depends on your ESP device
  Wire.begin(0,2);
  gyro.initialisation();
  Serial.println("MPU6050 Test");
  delay(1000);

  // Explicitly set the ESP8266 to be a WiFi-client
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
  Serial.println();
  Serial.print("IP Address:  "); Serial.println(WiFi.localIP());


}

void loop() {
  // read the sensor values

//Serial.print("AcX = ");
  //Serial.print(gyro.refresh('A', 'X'));           // Ask for the X axis of the Accelerometer and print it
  GyroX = (gyro.refresh('A', 'X'));
  //Serial.print(" | AcY = ");
  //Serial.print(gyro.refresh('A', 'Y'));           
  GyroY = (gyro.refresh('A', 'Y'));                 // Ask for the Y axis of the Accelerometer and print it
  //Serial.print(" | GyZ = ");
  GyroZ = (gyro.refresh('G', 'Z'));
  //Serial.println(gyro.refresh('G', 'Z'));         // Ask for the Z axis of the Gyroscope and print it, then carriage return

  posX = map(GyroX, -60, 90, 170, 10);      
  posY = map(GyroY, -90, 90, 180, 0);
  posZ = map(GyroZ, -110, 110, -30, 30);
  Serial.print(posX); Serial.print("      ");
  Serial.print(posY); Serial.print("      ");
  Serial.print(posZ); Serial.println(" ");


  posZ = posact + posZ; // add gyro value to actual position

  posact = posZ; // save actual servo position


  char intToPrint1[5]; char intToPrint2[5]; char intToPrint3[5];
  itoa(posX, intToPrint1, 10);
  itoa(posY, intToPrint2, 10);
  itoa(posZ, intToPrint3, 10);


  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }
  

  // We now create a URI for the request. Something like /data/?sensor_reading=123
  String url1 = "/data1/"; String url2 = "/data2/"; String url3 = "/data3/";
  url1 += "?sensor_1="; url2 += "?sensor_2="; url3 += "?sensor_3=";
  url1 += intToPrint1; url2 += intToPrint2; url3 += intToPrint3;

  // This will send the request to the server
  client.print(String("GET ") + url1 + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: keep-alive\r\n\r\n");
  client.print(String("GET ") + url2 + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: keep-alive\r\n\r\n");
  client.print(String("GET ") + url3 + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: keep-alive\r\n\r\n");
               
  delay(40);
}

the errors:
c:\Users\Asus\Documents\Arduino\libraries\GY6050-master\GY6050.cpp: In member function 'int GY6050::refresh(char, char)':
c:\Users\Asus\Documents\Arduino\libraries\GY6050-master\GY6050.cpp:38:37: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
38 | Wire.requestFrom(address, 14, true); // request a total of 14 registers
| ^
In file included from c:\Users\Asus\Documents\Arduino\libraries\GY6050-master\GY6050.cpp:11:
C:\Users\Asus\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\Wire/Wire.h:74:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int, int)'
74 | uint8_t requestFrom(int, int, int);
| ^~~~~~~~~~~
C:\Users\Asus\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\Wire/Wire.h:68:13: note: candidate 2: 'size_t TwoWire::requestFrom(uint8_t, size_t, bool)'
68 | size_t requestFrom(uint8_t address, size_t size, bool sendStop);
| ^~~~~~~~~~~
c:\Users\Asus\Documents\Arduino\libraries\GY6050-master\GY6050.cpp:38:37: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
38 | Wire.requestFrom(address, 14, true); // request a total of 14 registers
| ^
In file included from c:\Users\Asus\Documents\Arduino\libraries\GY6050-master\GY6050.cpp:11:
C:\Users\Asus\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\Wire/Wire.h:74:13: note: candidate 1: 'uint8_t TwoWire::requestFrom(int, int, int)'
74 | uint8_t requestFrom(int, int, int);
| ^~~~~~~~~~~
C:\Users\Asus\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\Wire/Wire.h:68:13: note: candidate 2: 'size_t TwoWire::requestFrom(uint8_t, size_t, bool)'
68 | size_t requestFrom(uint8_t address, size_t size, bool sendStop);
| ^~~~~~~~~~~
c:\Users\Asus\Documents\Arduino\libraries\GY6050-master\GY6050.cpp:78:1: error: control reaches end of non-void function [-Werror=return-type]
78 | }
| ^
cc1plus.exe: some warnings being treated as errors

exit status 1

Compilation error: exit status 1

kindly help me solve the issue

That's not something that you want to ignore. None of those are safe warnings. You need to address them all.

Since the errors are in the library and not your code, I think I'd look for a different library.

how do i address them.
I am not an expert in coding. could you guide me

In the c:\Users\Asus\Documents\Arduino\libraries\GY6050-master\GY6050.cpp file change this line of code

into

Wire.requestFrom((uint8_t) address, (size_t) 14, true); // request a total of 14 registers

that should help the compiler pick the right version of the requestFrom() function by hardcoding the types into the function call instead of letting the compiler decide which promotion to use.

thanks, it did remove the error of wire.h but didn't remove " error: control reaches end of non-void function [-Werror=return-type]"

c:\Users\Asus\Documents\Arduino\libraries\GY6050-master\GY6050.cpp: In member function 'int GY6050::refresh(char, char)':
c:\Users\Asus\Documents\Arduino\libraries\GY6050-master\GY6050.cpp:78:1: error: control reaches end of non-void function [-Werror=return-type]
78 | }
| ^
cc1plus.exe: some warnings being treated as errors

exit status 1

Compilation error: exit status 1

edit GY6050.cpp and line 78 before the closing } of the function add return 0;

the author of this library did not write great code...

Then I would choose a different library. This one is not very well written. You'll need some skills to make up for the poor code in the library.

Sometimes you get that when the return statements are all within conditional code. The author of the code is assuming (possibly correctly) that a condition to execute one of the return statements will always be met, but the compiler sees a possibility that no return statement will be executed.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.