title: GetProcAddress can't find function
body: <p>i try to load a library using <code>LoadLibrary</code> and <code>GetProcAddress</code> to use functions in this library. however, the dll is loaded fine but i dont get the function.</p>
  
  <p><strong>dll.h</strong></p>
  
  <pre><code>#ifndef TEST_DLL_H
  #define TEST_DLL_H
  
  void __declspec(dllexport) __stdcall tests();
  
  #endif // TEST_DLL_H
  </code></pre>
  
  <p><strong>dll.cpp</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "test_dll.h"
  
  void __declspec(dllexport) __stdcall tests() {
      std::cout &lt;&lt; "tests" &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>typedef void(*f_funci)();
  
  int main() {
      HMODULE hMod = LoadLibrary(L"plugins/test_dll.dll");
      if (!hMod)
          throw(std::runtime_error("failed to load dll"));
  
      f_funci f = (f_funci)GetProcAddress(hMod, "tests");
      if (!f) {
          std::cout &lt;&lt; GetLastError() &lt;&lt; "\n"; // code is 127 "The specified procedure could not be found."
          throw(std::runtime_error("could not locate function"));
      }
  
      f();
  }
  </code></pre>
  
  <p>so i tried to dump the dll (<code>dumpbin /exports</code>) and saw the tests functions is defined as <code>?tests@@YGXXZ</code>.</p>
  
  <pre><code>00000000 characteristics
  52DD9D2B time date stamp Mon Jan 20 23:03:23 2014
      0.00 version
         1 ordinal base
         1 number of functions
         1 number of names
  
  ordinal hint RVA      name
  
        1    0 00011037 ?tests@@YGXXZ = @ILT+50(?tests@@YGXXZ)
  
  Summary
  
      1000 .data
      1000 .idata
      3000 .rdata
      1000 .reloc
      1000 .rsrc
      B000 .text
     10000 .textbss
  </code></pre>
  
  <p>now if i try</p>
  
  <pre><code>f_funci f = (f_funci)GetProcAddress(hMod, "?tests@@YGXXZ");
  </code></pre>
  
  <p>it works.</p>
  
  <p>so my question is, <strong>why is the function resolution wrong?</strong></p>
  
  <h2>edit:</h2>
  
  <p>i'm using visual studio 2013 express.</p>
  
  <p><em>character set</em> is <strong>not set</strong>.</p>