templates under XP/debug compilation error using templates/XP

I get a compilation error when using templates in a debug build with nvcc under XP.
(
visual studio 2005, version 8.0.50727.42
compiler version 14.00.50727.42
)

A simple example, using the simpleTemplates sdk example project:

Add the following template function at the top of simpleTemplates.cu:

[font=“Courier”]
template
void mytest(dim3 grid, dim3 threads, unsigned int mem_size, T* g_idata, T* g_odata)
{
testKernel<<< grid, threads, mem_size >>>( g_idata, g_odata);
}
[/font]

Then call this function instead of calling testKernel directly in runTest():

[font=“Courier”]

// execute the kernel
//testKernel<<< grid, threads, mem_size >>>( d_idata, d_odata);
mytest(grid, threads, mem_size, d_idata, d_odata);

[/font]

I get the following errors:

[font=“Courier”]
1>------ Build started: Project: simpleTemplates, Configuration: EmuDebug x64 ------
1>Performing Custom Build Step
1>simpleTemplates.cu
1>tmpxft_00000fa4_00000000-3.cpp
1>tmpxft_00000fa4_00000000-6.ii
1>simpleTemplates.cu(142) : warning C4800: ‘float’ : forcing value to bool ‘true’ or ‘false’ (performance warning)
1>simpleTemplates.cu(52) : error C2065: ‘testKernel’ : undeclared identifier
1> simpleTemplates.cu(198) : see reference to function template instantiation ‘void mytest(dim3,dim3,unsigned int,T *,T *)’ being compiled
1> with
1> [
1> T=float
1> ]
1> simpleTemplates.cu(79) : see reference to function template instantiation ‘void runTest(int,char **,int)’ being compiled
1>simpleTemplates.cu(52) : error C2275: ‘T’ : illegal use of this type as an expression
1> simpleTemplates.cu(198) : see declaration of ‘T’
1>simpleTemplates.cu(52) : error C2059: syntax error : ‘)’
1>simpleTemplates.cu(52) : error C2275: ‘T’ : illegal use of this type as an expression
1> simpleTemplates.cu(198) : see declaration of ‘T’
1> simpleTemplates.cu(198) : see reference to function template instantiation ‘void mytest(dim3,dim3,unsigned int,T *,T *)’ being compiled
1> with
1> [
1> T=int
1> ]
1> simpleTemplates.cu(80) : see reference to function template instantiation ‘void runTest(int,char **,int)’ being compiled
1>simpleTemplates.cu(52) : error C2059: syntax error : ‘)’
1>Build log was saved at “file://c:\ajs\sw\simpleTemplates\x64\EmuDebug\BuildLog.htm”
1>simpleTemplates - 5 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
[/font]

This seems to work fine under linux and for non-debug builds.

Maybe I guess you want to use templates in your cu files?
But it will like this:

template
void mytest(dim3 grid, dim3 threads, unsigned int mem_size, T* g_idata, T* g_odata)
{
testKernel<<< grid, threads, mem_size >>>( g_idata, g_odata);
}

use mytest:

mytest(grid, threads, mem_size, d_idata, d_odata);
or
mytest(grid, threads, mem_size, d_idata, d_odata);
……