Which compiler are you using? Following code works with VS 2008.
#include <cstdlib>
template <class VAL_TYPE>
int sortFunction2(const void *arg1,const void *arg2)
{
VAL_TYPE* d1 = (VAL_TYPE*)arg1;
VAL_TYPE* d2 = (VAL_TYPE*)arg2;
if(*d1>*d2) return 1;
if(*d1<*d2) return -1;
return 0;
}
int main(int argc, char* argv[])
{
long double x[8] = {10, 9, 8, 7, 6, 5, 4, 3};
qsort(x, 8, sizeof(long double), sortFunction2<long double>);
return 0;
}
-Saurabh