title: Pointer typecasting in c
body: <p>I am writing an implementation of graphs in C language. I came across a situation where I am not able to figure out the reason for the way the compiler is behaving with a pointer typecast warning. 
  Here are the structures;</p>
  
  <pre><code>#define MAXV 10 
  typedef struct {
      int y;
      int weight;
      struct edgenode *next;
  } edgenode;
  
  
  typedef struct {
     edgenode *edge[MAXV+1];
     int degree[MAXV+1];
     // other info of graph
  } graph;
  
  // operation in some other function
  p-&gt;next = g-&gt;edge[x];
  </code></pre>
  
  <p>I got a pointer typecast warning[enabled by default] when I do this kind of operation.  </p>
  
  <p>I was not able to remove this warning even after trying to typecast with every possible cast.<br>
  Finally I made a code change in the structure and suddenly the warning was gone.
  The structure code change was this:-  </p>
  
  <pre><code>typedef struct edgenode {   // note that I have added structure name here
      // same as above definition
  } edgenode;
  
  // operation in some other function
  p-&gt;next = g-&gt;edge[x];
  </code></pre>
  
  <p>Now the warning is gone and code runs without any warnings.</p>
  
  <p>I do not understand <strong>why</strong> is this happening; can anybody help me with this problem?</p>