title: opaque (abstract) data types in C
body: <h3>File api.h</h3>
  
  <pre><code>#include &lt;stdio.h&gt;
  #ifndef API
  #define API
  
  struct trytag;
  typedef struct trytag try;
  
  void trial (try *);
  
  #endif
  </code></pre>
  
  <h3>File core.h</h3>
  
  <pre><code>#ifndef CORE
  #define CORE
  struct trytag
  {
      int a;
      int b;
  };
  #endif
  </code></pre>
  
  <h3>File func.c</h3>
  
  <pre><code>#include "api.h"
  #include "core.h"
  
  void trial (try *tryvar)
  {
      tryvar-&gt;a = 1;
      tryvar-&gt;b = 2;
  }
  </code></pre>
  
  <h3>File main.c</h3>
  
  <pre><code>#include "api.h"
  
  int main ()
  {
      try s_tryvar;
  
      trial(&amp;s_tryvar);
  
      printf("a = %d\nb = %d\n", s_tryvar.a, s_tryvar.b);
  }
  </code></pre>
  
  <p>When I compile, I get:</p>
  
  <pre><code>main.c:5: error: storage size of ‘s_tryvar’ isn’t known
  </code></pre>
  
  <p>If I include <code>core.h</code> in <code>main.c</code> this error doesn't come as try is defined in <code>core.h</code>. But I want the structure <code>try</code> to be hidden to <code>main.c</code> — it should not know the members of <code>try</code> structure. What am I missing?</p>