title: what does __declspec(dllexport) do , when add it before a import function
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2288293/windows-c-extern-declspecdllimport">Windows &amp; C++: extern &amp; __declspec(dllimport)</a><br>
    <a href="https://stackoverflow.com/questions/4489441/why-when-is-declspec-dllimport-not-needed">Why/when is __declspec( dllimport ) not needed?</a>  </p>
  </blockquote>
  
  
  
  <p>I want to write a DLL project. This project include several DLLs. They are <strong>dependent</strong>. I define some macros like follow :</p>
  
  <pre><code>#ifdef  MYDLL_DECL1
      #define  DLL_DECL __declspec(dllexport)
  #else
      #define DLL_DECL __declspec(dllimport)
  #endif
  </code></pre>
  
  <p>I defined MYDLL_DECL1...MYDLL_DECLn for <strong>each modules</strong>. Because I thought  if i define the same macro that it wouldn't work .  But I really want to define only one macro, and i wrote a testbed. I have two modules. In the second moudle's source file. I write code like follow:</p>
  
  <pre><code>#define  MYDLL_DECL
  #include "moudle1.h"
  #include "moudle2.h"
  </code></pre>
  
  <p>If I use the same macro name "MYDLL_DECL" ,for modle1's head file  I have defined  "MYDLL_DECL", so "DLL_DECL" is equal to   '__declspec(dllexport)'. Actually in module2 it should be equal to "__declspec(dllimport)", Because module2 import module1.  <strong>But I found it worked when I just define a same macro for two module. And I also find that the OpenCV also use this methold to its library</strong></p>