JosRi
February 2, 2017, 11:28pm
1
Hi there,
I am new to this kind of programming and I have a compiler warning on the Servo library:
C:\Program Files (x86)\Arduino\libraries\Servo\src\avr\Servo.cpp:184:39:
warning: unused parameter 'timer' [-Wunused-parameter]
static void finISR(timer16_Sequence_t timer)
I found the piece of code here:
static void finISR(timer16_Sequence_t timer)
{
//disable use of the given timer
#if defined WIRING // Wiring
if(timer == _timer1) {
#if defined(AVR_ATmega1281 )||defined(AVR_ATmega2561 )
TIMSK1 &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt
#else
TIMSK &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt
#endif
timerDetach(TIMER1OUTCOMPAREA_INT);
}
else if(timer == _timer3) {
#if defined(AVR_ATmega1281 )||defined(AVR_ATmega2561 )
TIMSK3 &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt
#else
ETIMSK &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt
#endif
timerDetach(TIMER3OUTCOMPAREA_INT);
}
#else
//For arduino - in future: call here to a currently undefined function to reset the timer
#endif
}
The error is in the first line: static void finISR(timer16_Sequence_t TIMER)
So my question is:
How can I repair this piece of code? I.e. The TIMER is obvious wrong, but what do I replace with?
Thanks,
Jos
system
February 2, 2017, 11:31pm
2
The error is in the first line
What error? A warning is NOT an error.
JosRi
February 2, 2017, 11:35pm
3
Yes, I agree that a warning is not an error.... But it annoyes me..... It should not be there and it pops up every time I compile my sketch. So I want to get rid of it...
system
February 2, 2017, 11:39pm
4
If it REALLY bothers you, add
timer = 57;
after
#else
When compiled for the Arduino, the compiler sees (after the post processor gets done):
static void finISR(timer16_Sequence_t timer)
{
//disable use of the given timer
//For arduino - in future: call here to a currently undefined function to reset the timer
}
And, of course, the argument timer is NOT used.
#else
timer = timer; //For arduino - in future: call here to a currently undefined function to reset the timer
#endif
This removes the warning without generating code.
system
February 2, 2017, 11:47pm
6
Whandall:
#else
timer = timer; //For arduino - in future: call here to a currently undefined function to reset the timer
#endif
This removes the warning without generating code.
I get why, after a minute. Perhaps you'd like to explain to OP why what works.
JosRi
February 2, 2017, 11:49pm
7
Thanks!
This did the trick:
timer = timer; //For arduino - in future: call here to a currently undefined function to reset the timer
The sketch compiled fine.
Cheers,
Jos
The "check for unused parameter"-instance of the compiler only looks for uses
and the optimizer will remove the statement which has no effect.