# Templated Functions on the Device

**URL:** <https://forums.developer.nvidia.com/t/templated-functions-on-the-device/952>\
**Category:** CUDA Programming and Performance\
**Created:** [June 21, 2007, 4:06pm UTC](https://forums.developer.nvidia.com/t/templated-functions-on-the-device/952 "2007-06-21T16:06:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathanbp](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@nathanbp](https://forums.developer.nvidia.com/u/nathanbp)\
**Post date:** [June 21, 2007, 4:06pm UTC](https://forums.developer.nvidia.com/t/templated-functions-on-the-device/952/1 "2007-06-21T16:06:58Z")

</div>

I am trying to use templated functions on the device declaring them like:

template **device** inline void add\_array( T\* array, unsigned int tid );

I am getting complier/linker errors as follows:  
“pmf\_math.h”, line 10: warning: extern inline function  
"add\_array(T _, unsigned int) [with T=int]" was referenced but not  
defined  
template **attribute** (( **device** )) inline void add\_array( T_ array, unsigned int tid );  
^

“pmf\_math.h”, line 10: warning: extern inline function “\_Z9add\_arrayIiEvPT\_j”  
was referenced but not defined  
extern **attribute** (( **device** ))inline void \_Z9add\_arrayIiEvPT\_j(int \*, unsigned);  
^

“pmf\_kernel.cu”, line 36: Error: Calls are not supported (found non-inlined call to \_Z9add\_arrayIiEvPT\_j)

Am I doing something else wrong or is there no way to use templated functions on the device with CUDA?

---

<div class="post-metadata">

**Author:** ![nathanbp](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@nathanbp](https://forums.developer.nvidia.com/u/nathanbp)\
**Post date:** [June 21, 2007, 7:01pm UTC](https://forums.developer.nvidia.com/t/templated-functions-on-the-device/952/2 "2007-06-21T19:01:25Z")

</div>

oops, I got this working by putting the templated functions into my header file. Guess it’s a C++ problem not a CUDA one (Templated functions need the entire function definition everywhere, not just the function declaration).
