title: alternative to defining struct in header file for 'error dereferencing pointer to incomplete type' in c
body: <p>I am aware that there are other questions about this which usually point to the standard solution of having both the <code>struct</code> and <code>typedef struct</code> declared and defined in the header file. However, I am looking at someone's else code which hasin the header:</p>
  
  <pre><code>struct A;
  typedef struct A A_t;
  </code></pre>
  
  <p>Then the struct A is defined in *.c file together with the implementation of other functions. The implementation of <code>A</code> includes many defines, etc that are as well included in *.c not in the header.</p>
  
  <p>Then in <code>main.c</code> the header is included and I have declared and defined new functions making use of (null) pointers to <code>A_t</code> which gives <code>error dereferencing pointer to incomplete type</code> when trying to access to a member of the struct.</p>
  
  <p>Is there an alternative to declare and define the struct and typedef into the header for this case?</p>
  
  <p>EDIT: Just to clarify that the original code foresees that the user creates some functions which are then passed to the main routines. For instance the user is supposed to create a function to connect to a socket, close a socket connection, transmit and receive data. Since I need an identifier/filedescriptor for the socket I have added an <code>int</code> to <code>A</code>'s definition which is what I can't dereference. I hope this clarifies the context.</p>