Mnementh
Mnementh

Reputation: 51311

What is the reason for this compiler-error with long long int under Visual Studio 2008?

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?

Upvotes: 2

Views: 273

Answers (1)

Mark B
Mark B

Reputation: 96251

A long long version of abs isn't specified in the standard.

26.5/3 shows us int and long versions.

26.5/5 gives us float, double, long double overloads.

No other overloads appear to be required, I suspect because long long isn't mandated or supported on all compilers/systems.

Upvotes: 2

Related Questions