title: c2011 type redefinition error, or c4677 signature of non-private member contains assembly private type
body: <p>I have a compilation problem, similar to this one: <a href="https://stackoverflow.com/questions/2977534/c-cli-public-ref-struct-generates-c2011-class-type-redefinition">stackoverflow q2977534</a>, where I got c2011 type redefinition errors.</p>
  
  <p>Let me describe my situation:<br>
  I have a <code>typesgeneral.h</code> (containing <code>public ref class CLocation</code>, <code>private enum class EnumParamType</code>, and others), that is included in a bunch of other .h-files like <code>CDrive.h</code>, <code>CIOSystem.h</code> and <code>CTcpipConnection.h</code>. <code>CIOSystem.h</code> also includes <code>CTcpipConnection.h</code>. All files (and their cpp implementations) were part of one large project. No problem so far.  </p>
  
  <p>I have recently decided to group the files that belong together and create managed DLLs, each one containing all files with similar purpose, e.g.  </p>
  
  <pre><code>swcore_network.dll:  
    CTcpipConnection.cpp, includes:
      CTcpipConnection.h, includes:
        typesgeneral.h, defines CLocation
    CUdpipConnection.cpp, includes
      CUdpipConnection.h, includes
        typesgeneral.h, defines CLocation
    CWnetShare.cpp ...
  </code></pre>
  
  <p><code>typesgeneral.h</code> is included in all of the .h files and because it has <code>#pragma once</code> the inclusion is working. But the same file is included in other .h files too (<code>CIOSystem.h</code>, ...), that build another DLL</p>
  
  <pre><code>swcore_io.dll:
    CIOSystem.cpp, includes
      CIOSystem.h, includes
        typesgeneral.h, defines CLocation
    CIOModuleType1.cpp, includes
      CIOModuleType1.h, includes
        typesgeneral.h, defines CLocation
    ...
    Reference to swcore_network.dll
  </code></pre>
  
  <p>Problem #1: <code>CLocation</code> from <code>typesgeneral.h</code> is referenced twice now in <code>swcore_io.dll</code> because it is public and therefore it is also a part from the <code>swcore_network.dll</code>'s interface. Thus I get the error c2011. #pragma once doesn't help here because there are different compilation processes.<br>
  Solution #1: I have made all classes from <code>typesgeneral.h</code> private, so only the main classes build the DLL interface.  </p>
  
  <p>Problem #2: I have other classes with public functions, that take a <code>CLocation</code> parameter. <code>CLocation</code> is private. That's why I get a warning C4677: non-private member contains private type.<br>
  Question #2: (already answered by tests) Will I be able at all to access these functions? I guess no...?<br>
  Solution #2: Although I did not expect it to work, it seems to. Obviously the compiler is smart enough to recognize that the symbol is defined at different locations, but it is identical... maybe someone can explain to me what is happening. </p>
  
  <p>Problem #3: If I made <code>CLocation</code> public, then I would have to remove all includes where the symbol is already imported by the reference. Now think of 2 independent DLLs, that both include <code>typesgeneral.h</code>, and then I include both DLLs in my application.<br>
  Question #3: possible or not? Do I have 2 different symbols with the same name then and get a compiler error?</p>
  
  <p>General questions:
  Is there maybe a more elegant approach to creating multiple among each other dependent DLLs?<br>
  Except making one large DLL that contains everything?<br>
  Or continuing including each needed .h and .cpp in the target project and always compiling everything?  </p>
  
  <p>Until I find a better solution, I will use the ones I have and suppress the compiler warning c4677 (<a href="http://msdn.microsoft.com/en-us/library/vstudio/jj715718.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/vstudio/jj715718.aspx</a>).</p>