title: Calling a template function from a C file
body: <p>I know that templates are not defined in C. However in my case, i have an API written in C++, which is used by an application written in C. I wish to add a template function in the API. The function is defined as follows in abc.cpp:</p>
  
  <pre><code>template&lt;typename T&gt; T function_name(T param1){
    ...
    ...
    return val;
  }
  </code></pre>
  
  <p>the declaration in abc.hpp as follows:</p>
  
  <pre><code>template&lt;typename T&gt; T function_name(T);
  </code></pre>
  
  <p>and this function is called from xyz.c as:</p>
  
  <pre><code>int a ,b = 5;
  a = function_name(b);
  </code></pre>
  
  <p>However, it shows the following error in both abc.cpp and abc.hpp:</p>
  
  <pre><code> error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘&lt;’ token
   template&lt;typename T&gt;
  </code></pre>
  
  <p>Even using extern "C" doesn't help(leads to error: template with C linkage). My doubt is, is it even possible to call this template function in such a way? If yes, how can this be achieved? Thank you. </p>