title: C++: error LNK2019: unresolved external symbol
body: <p>the following code produces this error:</p>
  
  <pre><code>error LNK2019: unresolved external symbol "char const * __cdecl nameOnly(char const *)"
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>const char* nameOnly(const char* namewpath)
  {
      const char* res = namewpath + strlen(namewpath);
      while (res &gt; namewpath) {
          const char* tmp = res - 1;
          if (*tmp == '/' || *tmp == '\\') break;
          --res;
      }
      return res;
  }
  </code></pre>
  
  <p>the above code is a plain c file and I'm compiling it with visual-C++.
  I don't get this error, when compiling with C-compiler.</p>
  
  <p><strong>UPDATE</strong>:
  I have tried using <code>extern</code>:</p>
  
  <pre><code>extern "C"{ 
   const char* nameOnly(const char* namewpath)
   {
      ...
      }
      return res;
   }
  }
  </code></pre>
  
  <p>and I get this error:</p>
  
  <pre><code>error C2059: syntax error : 'string'
  </code></pre>