title: C: Error expected expression before "struct name2
body: <p>Here's the declaration of the struct in "sprite.h"</p>
  
  <pre><code>typedef struct {
    int x,y;             /**&lt; current sprite position */
    int width, height;   /**&lt; sprite dimensions */
    int xspeed, yspeed;  /**&lt; current speeds in the x and y direction */
    char *map;           /**&lt; the sprite pixmap (use read_xpm()) */
  } Sprite;
  </code></pre>
  
  <p>And here's the pieces of code where we make use of them, in separate source files where we include the header.</p>
  
  <pre><code>Sprite *create_sprite(char *pic[], int x, int y, int xspeed, int yspeed) {
      //allocate space for the "object"
      Sprite *sp = (Sprite *) malloc ( sizeof(Sprite));
      if( sp == NULL )
          return NULL;
      // read the sprite pixmap
      sp-&gt;map = read_xpm(pic, &amp;(sp-&gt;width), &amp;(sp-&gt;height));
      if( sp-&gt;map == NULL ) {
          free(sp);
          return NULL;
      }
      else
      {
          sp-&gt;x =x;
          sp-&gt;y =y;
          sp-&gt;xspeed = xspeed;
          sp-&gt;yspeed = yspeed;
      }
  
      return sp;
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>if(xi==xf)
      Sprite* sp = create_sprite(xpm, xi, yi,0,speed); //error
  else
      Sprite* sp = create_sprite(xpm, xi, yi,speed,0); //error
  </code></pre>
  
  <p>This last piece of code is used in one of our "main" functions. When we try to compile our project using <code>make</code> we get the error in the title, refering to the expressions signaled above. Eclipse also doesn't highlight <code>Sprite</code> outside of the header file...</p>