The following code (simplified example, that triggers the error) doesn’t compile with VS 2008:
#include <math.h>
void test()
{
long long int val1 = 1;
long long int val2 = 2;
long long int val3 = abs<long long int>(val1 / val2);
}
That gives an compiler-error (C2062) on the third line – the type __int64 is unexpected. What is the reason for this error? How can it be avoided?
A
long longversion ofabsisn’t specified in the standard.26.5/3 shows us
intandlongversions.26.5/5 gives us
float,double,long doubleoverloads.No other overloads appear to be required, I suspect because
long longisn’t mandated or supported on all compilers/systems.