title: VS 2010: error LNK2019: unresolved external symbol "extern "C" void * __cdecl
body: <p>I'm new in C++, I tried to copy this code and run in visual studio 2010. But it is giving unresolved extern 'c' error and another unresolved token "extern "C" as listed below the code.</p>
  
  <p><strong>This is the code causing the errors :</strong></p>
  
  <pre><code>#ifdef _MANAGED     // Works only with managed C++
  #pragma once
  #pragma managed(push, on)
  #include &lt;stdlib.h&gt;     //free
  
  typedef void (__cdecl *_PVFV)(void);
  extern "C" void * __cdecl _decode_pointer(void *);
  extern "C" void * __cdecl _encoded_null();
  
  // crtdll.c
  extern "C" _PVFV *__onexitbegin;
  extern "C"  _PVFV *__onexitend;
  
  
  
  void CrtDestroyStatics(void)
  {
      _PVFV * onexitbegin = (_PVFV *)_decode_pointer(__onexitbegin);
      if (onexitbegin)
      {
          _PVFV * onexitend = (_PVFV *)_decode_pointer(__onexitend);
          _PVFV function_to_call = NULL;
  
          /* save the start and end for later comparison */
          _PVFV * onexitbegin_saved = onexitbegin;
          _PVFV * onexitend_saved = onexitend;
  
          while (1)
          {
              _PVFV * onexitbegin_new = NULL;
              _PVFV * onexitend_new = NULL;
  
              /* find the last valid function pointer to call. */
              while (--onexitend &gt;= onexitbegin &amp;&amp; (*onexitend == NULL || *onexitend == _encoded_null()))
              {
                  /* keep going backwards. */
              }
  
              if (onexitend &lt; onexitbegin)
              {
                  /* there are no more valid entries in the list, we are done. */
                  break;
              }
  
              /* cache the function to call. */
              function_to_call = (_PVFV)_decode_pointer(*onexitend);
  
              /* mark the function pointer as visited. */
              *onexitend = (_PVFV)_encoded_null();
  
              /* call the function, which can eventually change __onexitbegin and __onexitend */
              (*function_to_call)();
  
              onexitbegin_new = (_PVFV *)_decode_pointer(__onexitbegin);
              onexitend_new = (_PVFV *)_decode_pointer(__onexitend);
  
              if ( ( onexitbegin_saved != onexitbegin_new ) || ( onexitend_saved != onexitend_new ) )
              {
                  /* reset only if either start or end has changed */
                   __onexitbegin = onexitbegin_saved = onexitbegin_new;
                   __onexitend = onexitend_saved = onexitend_new;
              }
  
              break;
          }
          /*
          * free the block holding onexit table to
          * avoid memory leaks.  Also zero the ptr
          * variables so that they are clearly cleaned up.
          */
  
          free ( onexitbegin ) ;
  
          __onexitbegin = __onexitend = (_PVFV *)_encoded_null();
      }
  
  } //CrtDestroyStatics
  
  #pragma managed(pop)
  #endif
  </code></pre>
  
  <p><strong>And here is the linker errors:</strong></p>
  
  <pre><code>Error   4   error LNK2019: unresolved external symbol "extern "C" void * __cdecl _decode_pointer(void *)" (?_decode_pointer@@$$J0YAPEAXPEAX@Z) referenced in function "void __cdecl CrtDestroyStatics(void)" (?CrtDestroyStatics@@$$FYAXXZ)
  Error   3   error LNK2028: unresolved token (0A000F2F) "extern "C" void * __cdecl _decode_pointer(void *)" (?_decode_pointer@@$$J0YAPEAXPEAX@Z) referenced in function "void __cdecl CrtDestroyStatics(void)" (?CrtDestroyStatics@@$$FYAXXZ)
  </code></pre>
  
  <p>Although I have those libraries values inherited for Additional Dependencies in Linker->Input </p>
  
  <pre><code>kernel32.lib
  user32.lib
  gdi32.lib
  winspool.lib
  comdlg32.lib
  advapi32.lib 
  </code></pre>
  
  <p>Please tell me what wrong I have committed?</p>