title: gcc - error: dereferencing pointer to incomplete type
body: <p>I have a rather convoluted set of nested structs/unions as shown:</p>
  
  <pre><code>typedef enum {
      expr_BooleanExpr,
      expr_ArithmeticExpr
  } expr_type;
  
  typedef union {
      struct BooleanExpr *_bool;
      struct ArithmeticExpr *_arith;
  } u_expr;
  
  typedef struct {
      expr_type type;
      u_expr *expr;
  } Expression;
  
  typedef struct {
      Expression *lhs;
      char *op;
      Expression *rhs;
  } BooleanExpr;
  
  typedef struct {
      Expression *lhs;
      char *op;
      Expression *rhs;
  } ArithmeticExpr;
  </code></pre>
  
  <p>gcc is happy for me to create an Expression struct containing a BoolExpression value in its union field as shown:</p>
  
  <pre><code>Expression *BooleanExpr_init(Expression *lhs, char *op, Expression *rhs) {
  
      BooleanExpr *_bool = safe_alloc(sizeof(BooleanExpr));
      _bool-&gt;lhs = lhs;
      _bool-&gt;op = op;
      _bool-&gt;rhs = rhs;
  
      Expression *the_exp = safe_alloc(sizeof(Expression));
      the_exp-&gt;type = expr_BooleanExpr;
      the_exp-&gt;expr-&gt;_bool = _bool;
  
      return the_exp;
  }
  </code></pre>
  
  <p>although  it gives a warning: <strong>assignment from incompatible pointer type [enabled by default]</strong> for the line: <code>the_exp-&gt;expr-&gt;_bool = _bool;</code></p>
  
  <p>However, when accessing the inner expressions such as <code>lhs</code> and <code>rhs</code>, with an expression like </p>
  
  <pre><code>an_expr-&gt;expr-&gt;_bool-&gt;rhs
  </code></pre>
  
  <p>where <code>an_expr</code> is a previously created Expression struct, I get the error specified in the title of this post.</p>
  
  <p>Much of what I've read says that this results from the use of the <code>-&gt;</code> operator where the <code>.</code> operator is required. However this is not appropriate since everything is a pointer, so the implicit dereference of the <code>-&gt;</code> operator is required.</p>
  
  <p>Any ideas?</p>