The const qualifiers were implicitly discarded here and there. Avoid that either by adding the constness, or casting it away when a const variable is passed to a function that is defined as non-const but effectively expect a const.
It was hidden behind a macro that was never defined anywhere.