My team is writting code to be compiled for both Windows (using VS2015
) and Android (using GCC 4.9
invoked by QtCreator
).
We figured out that Android binaries had a problem with abs
function.
double a = 1.0;
double b = 0.5;
std::cout << abs( a - b ) << std::endl;
std::cout << std::abs( a - b ) << std::endl;
Displays:
1
0.5
This is a known issue, found this topic (among others): Strange bug in usage of abs() I encountered recently
There are lots of places where we use abs
, I'll replace them all by std::abs
. Fine. But how can I prevent abs
to be used again in the future?
Found this topic: Avoiding compiler issues with abs(), but it did not help.
I can't enable treating all warnings as errors (-Werror -Wall) because g++ is much less permissive than MSVC. Even if we make the effort to compile with 0 warning on MSVC, we still get tons of them with g++ (among them there could be one about abs being used badly) and we historically ignore them. Fixing them all would take us too much effort.