title: expression must be a pointer to a complete object type from macro
body: <p>I'm attempting to integrate libbeanstalkd into an embedded system so I'm having to make some minor changes. So far I've been able to replace/fix some OS specific code but then I came to this error. I've fixed these type of errors before <strong><em>"expression must be a pointer to a complete object type"</em></strong> but what's really getting me aside from the fact that I'm sure the header for the macro and the used objects is that this macro is used a few lines BEFORE where the compiler error is thrown. Can someone help me understand what the issue is?</p>
  
  <p>Source <code>arrayqueue.h</code></p>
  
  <pre><code>#ifndef ARRAYQUEUE_H
  #define ARRAYQUEUE_H 
  
  #define AQ_DEFINE_STRUCT(struct_name, node_type) \
  struct struct_name {                             \
      node_type *nodes;                            \
      size_t     size;                             \
      size_t     used;                             \
      off_t      front;                            \
      off_t      rear;                             \
  }
  
  #define AQ_NODES_FREE(q) ( (q)-&gt;size - (q)-&gt;used )
  #define AQ_FULL(q)       ( (q)-&gt;used == (q)-&gt;size )
  #define AQ_EMPTY(q)      ( (q)-&gt;used == 0 )
  
  #define AQ_REAR_(q)      ( (q)-&gt;nodes + (q)-&gt;rear )
  #define AQ_REAR(q)       ( AQ_EMPTY(q) ? NULL : AQ_REAR_(q) )
  
  #define AQ_FRONT_(q)     ( (q)-&gt;nodes + (q)-&gt;front )
  #define AQ_FRONT(q)      ( AQ_FULL(q) ? NULL : AQ_FRONT_(q) )
  
  #define AQ_DEQ_FIN(q)    ( (q)-&gt;rear  = ( (q)-&gt;rear  + 1 ) % (q)-&gt;size, (q)-&gt;used-- )
  #define AQ_ENQ_FIN(q)    ( (q)-&gt;front = ( (q)-&gt;front + 1 ) % (q)-&gt;size, (q)-&gt;used++ )
  
  #endif /* ARRAYQUEUE_H */
  </code></pre>
  
  <p>Source <code>ioqueue.h</code>:</p>
  
  <pre><code>#ifndef _IOQUEUE_H
  #define _IOQUEUE_H
  
  #include &lt;stddef.h&gt;
  #include &lt;vsocket.h&gt;
  #include "arrayqueue.h"
  #include "verixmissing.h"
  
  struct _ioq_node {
      struct iovec *vec;
      int    autofree;
  };
  
  AQ_DEFINE_STRUCT(_ioq, struct _ioq_node);
  
  typedef struct _ioq ioq;
  typedef struct _ioq_node ioq_node;
  
  #define IOQ_NODES_READY(q)   ((q)-&gt;used ? ( (q)-&gt;front &lt;= (q)-&gt;rear ? (q)-&gt;size - (q)-&gt;rear : (q)-&gt;used ) : 0)
  #define IOQ_PEEK_POS(q, i)   ((AQ_REAR_(q)+i)-&gt;vec)
  #define IOQ_REAR_(q)         IOQ_PEEK_POS(q,0)
  #define IOQ_REAR(q)          (AQ_EMPTY(q) ? NULL : IOQ_REAR_(q))
  
  void    ioq_enq_(ioq *q, void *data, ssize_t data_len, int autofree);
  int     ioq_enq(ioq *q, void *data, ssize_t data_len, int autofree);
  ssize_t ioq_dump(ioq *q, int fd);
  ioq    *ioq_new(size_t size);
  void    ioq_free(ioq *q);
  
  #endif /* _IOQUEUE_H */
  </code></pre>
  
  <p>Source <code>ioqueue.c</code>:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;vsocket.h&gt;
  #include "arrayqueue.h"
  #include "ioqueue.h"
  
  ...
  
  ssize_t ioq_dump(ioq *q, int fd)
  {
      size_t  bytes_expected = 0, nodes_ready = IOQ_NODES_READY(q), i;
      ssize_t bytes_written, nodes_written  = 0;
  
      for (i = 0; i &lt; nodes_ready; ++i)
          bytes_expected += IOQ_PEEK_POS(q,i)-&gt;iov_len;
  
      if ( ( bytes_written = writev(fd, IOQ_REAR_(q), nodes_ready) ) &lt; bytes_expected )
          switch (bytes_written) {
              case -1:
                  return -1;
              default:
                  while ( ( bytes_written -= IOQ_REAR_(q)-&gt;iov_len ) &gt; 0 ) {
                      IOQ_DUMP_FIN(q, 1);
                      ++nodes_written;
                  }
                  if ( bytes_written &lt; 0 ) {
                      IOQ_REAR_(q)-&gt;iov_base += IOQ_REAR_(q)-&gt;iov_len + bytes_written;
                      ^---------------------- ERROR!
                      IOQ_REAR_(q)-&gt;iov_len   = -bytes_written;
                  }
                  return nodes_written;
          }
      else {
          IOQ_DUMP_FIN(q, nodes_ready);
          return nodes_ready;
      }
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>"..\Source\libs\libbeanstalkd\ioqueue.c", line 125: Error:  #852: expression must be a pointer to a complete object type
                      IOQ_PEEK_POS(q, 0)-&gt;iov_base += IOQ_REAR_(q)-&gt;iov_len + bytes_written;
                      ^
  </code></pre>
  
  <p>If it helps, Eclipse expands the macro to: <code>((( (q)-&gt;nodes + (q)-&gt;rear )+0)-&gt;vec)</code></p>