Warning disappears after second compilation?

A simple question, every time I compile for the second time a warning error code disappears. Is this normal in the Arduino IDE?

If you didn't change the file which created the warning and you didn't change the settings ( e.g. the board ), its usually not compiled again, but the already compiled object file is reused. No compilation - no warning.

I made the code and copied it, saw the warnings, which at first don't even seem to make sense. I didn't change anything, I copied it again and the warnings didn't appear.

Sorry, but I don't understand what you really did. And which IDE version are you using?

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);
    
   }
}

Your code likely depends on a library that is poorly written and throws a warning

Upon the first compile the library code is compiled and thus you see the warning

Upon further compile, the library is already compiled and thus does not go through the compiler stage - only the linker. So you don’t see the warning any more

I find it really annoying when library owners never bother to fix the code that causes warnings. There are more than just Software Serial that have that problem.

There is some relevant discussion about the idea of caching the warnings along with the compiled objects and replaying them during the subsequent builds when they wouldn't otherwise be shown due to the use of the cache:

It is more significant than ever now because Arduino IDE 2.x uses a cache that can persist between IDE sessions rather than clearing the cache on exit as Arduino IDE 1.x did.

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