title: ‘struct ...’ has no member named
body: <p>Why do I keep getting this errors:</p>
  
  <blockquote>
    <p>struct has no members [-Wpedantic]<br> ‘struct cheque’ has no member named
    ‘refc’<br> ‘struct cheque’ has no member named ‘valor’</p>
  </blockquote>
  
  <p>etc. The code is as below</p>
  
  <hr>
  
  <pre><code>#ifndef _ITEM_
  #define _ITEM_ 
  
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  #define key (a) (a != NULL ? a-&gt;refc : "")      
  #define less (a,b) (strcmp (a,b)&lt;0)
  #define eq(a,b) (strcmp (a,b) == 0)
  #define NULLitem NULL
  
  typedef long int* Key;                  
  
  typedef struct cheque {                 
      int valor
      long int refe
      long int refb
      long int* refc
  
  }*Item;                         
  
  Item newItem (int valor, long int refe, long int refb, long int* refc);
  void deleteItem (Item a);
  void visitItem (Item a);
  
  #endif
  </code></pre>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>Now I'm facing folloeing errors, </p>
  
  <blockquote>
    <p>Item.c:6:36: error: expected ‘;’, ‘,’ or ‘)’ before ‘refe’ Item
    newItem (int valor, long item refe, long item refb, long item* refc) ^
    Item.c: In function ‘visitItem’:</p>
    
    <p>Item.c:32:2: warning: format ‘%d’ expects argument of type ‘int’, but
    argument 2 has type ‘long int’ [-Wformat=] printf("refe: %d\n",
    a->refe); ^</p>
    
    <p>Item.c:33:2: warning: format ‘%d’ expects argument of type ‘int’, but
    argument 2 has type ‘long int’ [-Wformat=] printf("refb: %d\n",
    a->refb); The code is as below</p>
  </blockquote>
  
  <p><strong>item.h</strong></p>
  
  <pre><code>#ifndef _ITEM_
  #define _ITEM_ 
  
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  #define key (a) (a != NULL ? a-&gt;refc : "")      
  #define less (a,b) (strcmp (a,b)&lt;0)
  #define eq(a,b) (strcmp (a,b) == 0)
  #define NULLitem NULL
  
  typedef long int* Key;                  
  
  typedef struct cheque {                 
      int valor;
      long int refe;
      long int refb;
      long int* refc;
  
  }*Item;                         
  
  Item newItem (int valor, long int refe, long int refb, long int* refc);
  void deleteItem (Item a);
  void visitItem (Item a);
  
  #endif
  </code></pre>
  
  <p><strong>item.c</strong></p>
  
  <pre><code>#include "Item.h"
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  
  Item newItem (int valor, long item refe, long item refb, long item* refc)
  {
  
      Item x = (Item) malloc (sizeof(struct cheque));
  
      x-&gt;valor = valor;
      x-&gt;refe = refe;
      x-&gt;refb = refb;
      x-&gt;refc = strdup(refc);
  
      return x;
  }
  
  
  void deleteItem (Item a)
  {
      free(a-&gt;refc);
      free(a);
  
  }
  
  
  void visitItem (Item a)
  {
  
      printf("valor: %d\n", a-&gt;valor);
      printf("refe: %d\n", a-&gt;refe);
      printf("refb: %d\n", a-&gt;refb);
      printf("refc: %ld\n", a-&gt;refc);
  
  }
  </code></pre>
  
  <hr>
  
  <blockquote>
    <p>EDIT_v2</p>
  </blockquote>
  
  <pre><code>Item newItem (int valor, long int refe, long int refb, long int* refc)
  
  printf("valor: %d\n", a-&gt;valor);
  printf("refe: %ld\n", a-&gt;refe);
  printf("refb: %ld\n", a-&gt;refb);
  printf("refc: %p\n", a-&gt;refc);
  </code></pre>
  
  <p>After correcting those mistakes I got the following errors:</p>
  
  <blockquote>
    <p>Item.c: In function ‘newItem’: Item.c:14:2: warning: implicit
     declaration of function ‘strdup’ [-Wimplicit-function-declaration]</p>
    
    <p>x->refc = strdup(refc);   ^ Item.c:14:10: warning: assignment makes
     pointer from integer without a cast [enabled by default]   x->refc =
     strdup(refc);</p>
    
    <p>Item.c: In function ‘visitItem’: Item.c:34:2: warning: format ‘%p’
    expects argument of type ‘void *’, but argument 2 has type  ‘long int
    *’ [-Wformat=]   printf("refc: %p\n", a->refc);</p>
  </blockquote>
  
  <p><strong>Edit_ v3</strong></p>
  
  <p>1 problem fixed
  Correction:</p>
  
  <pre><code>x-&gt;refc = refc;
  </code></pre>
  
  <p>Errors atm:</p>
  
  <blockquote>
    <p>Item.c: In function ‘visitItem’: Item.c:34:2: warning: format ‘%p’
    expects argument of type ‘void *’, but argument 2 has type ‘long int
    *’ [-Wformat=]   printf("refc: %p\n", a->refc);</p>
  </blockquote>