C++ discards qualifiers

Anthony picture Anthony · Jan 17, 2014 · Viewed 38.9k times · Source

I have this error:

BSPArduino.cpp:316: error: passing 'const BSPArduino' as 'this' argument of 'virtual void BSPArduino::enableWdt(const WATCHDOG_TIMER_DELAY&, const ___bool&)' discards qualifiers

This method is define like that:

void BSPArduino::enableWdt(const WATCHDOG_TIMER_DELAY &delay, const ___bool &enable)

I want to call it like that:

enableWdt(this->watchdogTimer, ___false);

With:

WATCHDOG_TIMER_DELAY watchdogTimer;

I don't understand why this build error...

Thank you so much for your help

Anthony

Answer

Bids picture Bids · Jan 17, 2014

BSPArduino::enableWdt() is a non-const method. If you try and call a non-const method from a const one you will get this error.

Essentially the error is trying to tell you that you are discarding the constness of "this".