views:

67

answers:

2

I'd like to build the olb3d library with my visual studio 2005 compiler but this failes due to template errors.

To be more specific, the following expression seem to be a problem:

void function(T u[Lattice<T>::d])

On the website of the project is stated that prpably my compiler is not capable of such complicated template expressions - one should use the gcc 3.4.1.

My question is now if there is a way to upgrade my vs c++ compiler so it can handle template expressions on the level as the gcc 3.4.1? Maybe it helps if I get a newer version of visual studio?

Cheers C.

+2  A: 

Buy a newer version of Visual Studio. 2005 is quite old and not very conformant. You can always test the new one first by downloading Visual C++ Express.

Marcelo Cantos
I tried VS 2010 but the compiler errors are still there... the template code of olb3d seems to be odd...
chris
A: 

The compiler says that it cannot deduce the template type. You can always help it out by specifying the type itself in your code.

foo<int>(some_int_array);

However, the part between [] that is tripping it up is completely meaningless. Arrays decay into pointers and the value is ignored in the first place. You can just comment out that part if this is a real example.

If you take the array by reference, VC++2005 doesn't appear to have any problem with it either:

template <class T>
void function(T (&arr)[Lattice<T>::n]);

(Is it possible that the case that doesn't compile is just so meaningless that no-one ever bothered to check if things like that work?)

UncleBens
You are absolutely right. They should have written just func(T* u) and it would have worked... but the source of olb3d is full of this odd template statements... I guess I will give up from trying to compile it within the windows environment.
chris