Warning notices with list of commands not used in the sketch

Guys, when compiling a code in the Arduino IDE without errors, however some warnings appear. How do I know these warnings haven't harmed my program?

I made a code for ATtiny85 and received these warnings and the commands mentioned in the warnings were not used in the code. That's why I'm in doubt. Follow the warnings and the program.

warning: unused parameter 'pin' [-Wunused-parameter]
inline void DebugPulse(uint8_t pin, uint8_t count)

warning: unused parameter 'pin' [-Wunused-parameter]
inline void DebugPulse(uint8_t pin, uint8_t count)

warning: always_inline function might not be inlinable [-Wattributes]
void SoftwareSerial::setRxIntMsk(bool enable)

warning: always_inline function might not be inlinable [-Wattributes]
void SoftwareSerial::recv()

#include <SoftwareSerial.h>


#define SERIAL_TX PINB0
#define SERIAL_RX PINB1



int ADC1 = A1;
int ConvertValue = 0; // Variable to store the converted value of ADC0
int PowerValue = 0; // Variable to store the power value
int PreviousPowerValue = 0; // Variable to store the previous power value
unsigned long ADCTime = 0; //Time for reading the analog input
unsigned long SerialTime = 0; //Time for serial communication with the HMI


// Variables for analog reading smoothing
const int NReadings = 20; // Number of samples for smoothing. The higher the more smoothing and slow to react
int Reads[NLreads]; // Array with 20 indexes
int Index = 0; // Current index value
long Total = 0; // Value of sums of readings
int Average = 0; // Average of readings


SoftwareSerial mySerial(SERIAL_RX, SERIAL_TX);





void setup() {
   // put your setup code here, to run once:

   pinMode(PINB2, INPUT); // AN0 input (PB2 - Pin 7)
   pinMode(PINB1, INPUT); // RX input (PB1 - Pin 6)
   pinMode(PINB0, OUTPUT); // TX output (PB0 - Pin 5)

   mySerial.begin(9600); //Start serial communication with baud rate = 9600
   delay(1000);
}





void loop() {
   // put your main code here, to run repeatedly:

   if (millis() >= ADCTTime + 20) { // Reads the analog input every 20ms

     ADCTime = millis();

     ConvertValue = analogRead(ADC1); // Read the analog input

     //Power Reading Smoothing
     Total = Total - Readings[Index];
     Readings[Index] = ConvertedValue;
     Total = Total + Reads[Index];
     Index = Index + 1;

     if (Index >= NReadings) {
       Index = 0;
     }

     Average = Total / NReadings;

     PowerValue = map(Average, 0, 1023, 0, 100); // Remaps a number from one range to another
     PowerValue = constrain(PowerValue, 0, 100); // Constrain a number to fall within a range
   }


  if ((millis() >= ADCTime + 200) && (PowerValue != PreviousPowerValue)) { // Performs serial communication every 200ms with changes in the power value

     TimeSerial = millis();
     PreviousPowerValue = PowerValue;

       mySerial.print(PowerValue);
    
   }
}

I always try to fix any warnings. A warning may not stop compilation, but can effect the running of the code.

If they come from a library I will make sure that I have the latest version of the library.

Often I can find help by doing a search (Google) for the warning. Most of the time I find what I need to know to fix it (or ignore it).

const byte digPin = 2;

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

void loop()
{
  bool pinValue = digitalRead(digPin);
  if(pinValue = LOW) // = for assignment, == for compare
  {
    Serial.print("low");
  }  
}

warning: suggest parentheses around assignment used as truth value [-Wparentheses]

void loop()
{
  bool pinValue = digitalRead(digPin);
  if(pinValue == LOW);   \\ ; ends the if
  {
    Serial.print("low");
  }  
}

warning: suggest braces around empty body in an 'if' statement [-Wempty-body]

A couple examples of common mistakes that result in warnings that shouldn't be ignored.

1 Like

I'm using Ide arduino 2.1.0, how can I always have the library always updated?

Is this done automatically?

I don't know if this happens all the time, because I haven't even been in contact with the Ardduino IDE for 15 days, but the first time I compile the code, the warnings appear. If I then compile again the warnings are no longer shown.

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