title: How to "uninclude" a header file?
body: <p>I have a class in the file <code>AType.h</code> and it is implemented in AType.cpp.</p>
  
  <pre><code># include "PrivateType.h"
  
  class AType{
      private:
      int a, b, c;
      PrivateType varX;
  
      public:
      ...
  };
  </code></pre>
  
  <p>I want to use the class AType in the file <code>main.cpp</code> and I will need to include <code>AType.h</code>, but I want to avoid the inclusion of <code>PrivateType.h</code> in main.cpp.<br>
  I cannot create <code>varX</code> with malloc/new.<br>
  main.cpp have to know the size of AType at compile-time.</p>
  
  <p><strong>Current solution:</strong> (It is bad)  </p>
  
  <p>1 - Create a program to print <code>sizeof(AType)</code>.<br>
  2 - Change the header:</p>
  
  <pre><code># ifdef ATYPE_CPP
      # include "PrivateType.h"
  #endif
  
  class AType{
      private:
      # ifdef ATYPE_CPP
          int a, b, c;
          PrivateType varX;
      # else
          char data[ the size that was printed ];
      # endif
  
      public:
      ...
  };
  </code></pre>
  
  <p>3 - And AType.cpp will start with:</p>
  
  <pre><code># define ATYPE_CPP
  # include "AType.h"
  </code></pre>
  
  <p><strong>Edit 1</strong></p>
  
  <p>Is there a way or tool to automatically change a complex struct into C primitive types?<br>
  I do not want to have to open header files and find the structs.</p>
  
  <p>If PrivateType is:</p>
  
  <pre><code>struct DataType {
      float a, b;
  };
  class PrivateType {
      void* a;
      int b;
      short c;
      DataType x;
  
      ... functions
  };
  </code></pre>
  
  <p>AType would be changed to:</p>
  
  <pre><code>class AType {
      int a, b, c;
      struct x {
          void* a;
          int b;
          short c;
          struct x2{
              float a, b;
          };
      };
  };
  </code></pre>
  
  <p>And I would handle copy/equality methods separately.<br>
  I use GCC or Clang.</p>
  
  <p><strong>Edit 2</strong><br>
  <strong>A new solution?</strong></p>
  
  <p>It is for GCC.</p>
  
  <p>1 - Get <code>sizeof(AType)</code> and <code>__alignof__(AType)</code>.<br>
  2 - Change the header:</p>
  
  <pre><code># ifdef ATYPE_CPP
      # include "PrivateType.h"
  #endif
  
  class AType{
      private:
      # ifdef ATYPE_CPP
          int a, b, c;
          PrivateType varX;
      # else
          char data[ 'the sizeof(AType)' ];
      # endif
  
      public:
      ...
  }
  # ifdef ATYPE_CPP
      ;
  # else
      __attribute__ (( aligned( 'The __alignof__(AType)' ) ));
  # endif
  </code></pre>
  
  <p>3 - Write all copy/equality methods in AType.cpp.  </p>
  
  <p>Will it work?</p>