title: error C2011: 'member' : 'struct' type redefinition on moving a struct to a new header file
body: <p>I had a .h file with some class code - overlay.h</p>
  
  <pre><code>    #include&lt;iostream&gt;
      #include&lt;boost/thread.hpp&gt; 
      #include&lt;vector&gt;
      #include&lt;boost/asio.hpp&gt; 
      #include &lt;string&gt;
      #include &lt;boost/serialization/vector.hpp&gt;
      #include &lt;boost/archive/text_oarchive.hpp&gt; 
      #include &lt;boost/archive/text_iarchive.hpp&gt; 
      #include &lt;sstream&gt; 
      #include &lt;boost/tuple/tuple.hpp&gt;
      #include&lt;member.h&gt;
      using boost::asio::ip::tcp;
  
      class overlay_server{...};
  
  struct member{
      std::string ip_address;
      short int port;
  
      template&lt;class Archive&gt;
      void serialize(Archive &amp; ar, const unsigned int version)
      {
          ar &amp; ip_address;
          ar &amp; port;
      }
  };
  </code></pre>
  
  <p>Now I moved the struct to another new file called member.h
  and included this file so my class overlay_server could use it.
  Now when I build the program I get the error.</p>
  
  <p>What changes should I make to make this work?
  I read about header guards on SO, but couldnt really understand how to implement it here to solve the problem.</p>
  
  <p>----edit----</p>
  
  <p>member.h</p>
  
  <pre><code>struct member{
      std::string ip_address;
      short int port;
  
      template&lt;class Archive&gt;
      void serialize(Archive &amp; ar, const unsigned int version)
      {
          ar &amp; ip_address;
          ar &amp; port;
      }
  };
  </code></pre>
  
  <p>run.cpp</p>
  
  <pre><code>    #include&lt;overlay_server.h&gt;
  #include&lt;overlay_client.h&gt;
  
  int main(){
  
      overlay_server overlay_server_(8002);
      boost::thread thread_(boost::bind(&amp;overlay_server::member_list_server, overlay_server_));
  
  
      overlay_client overlay_client_("127.0.0.1",8002);
      overlay_client_.member_list_client();
  
      thread_.join();
  }
  </code></pre>
  
  <p>I dont have redefinition of struct anywhere.
  I have another class called overlay_client it also uses struct member.</p>
  
  <p>In my main function, i create objects of both overlay_server and overlay_client.
  Now my program runs only if member.h is included in overlay_server.h (though code in both overlay_server and overly_client requires it)
  if its included in both then i get the redefinition error</p>
  
  <p>why?</p>
  
  <p>----edit----</p>
  
  <p>this code in my member.h solves the issue
  <a href="https://stackoverflow.com/questions/5825084/compile-error-struct-type-redefinition-although-its-the-first-definition-fo/5825130#5825130">Compile error &quot;&#39;struct&#39; type redefinition&quot; although it&#39;s the first definition for it</a></p>