title: warning in extern declaration
body: <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  #define GREY 1
  #define BLACK 0
  #define WHITE 2
  typedef struct node * graph;
  typedef struct stack * snode;
  
  graph cnode(int data);          //cnode is to create a node for graph
  void cgraph(void);
  struct node {
          int data, color;
          struct node *LEFT, *RIGHT, *TOP, *DOWN;
  };//this structure defines a node of the graph
  
  struct stack {
  struct stack *priv;
  struct cgraph *graph_node;
  };// this is to define a structure which should hold node of a structure
  
      extern snode sroot;
  </code></pre>
  
  <p>I defined a header file (declaration.h) as above and following is a c program(stack.c)
  I am making which would be used in the library I am developing</p>
  
  <pre><code>#include&lt;declarations.h&gt;
  void cstack (graph temp);
  void stackpush(snode stemp);
  extern int stack_counter = 0;
  
  sroot=NULL;
  void cstack (graph gtemp) //cstack is to create stack
  {
     snode spriv,some;
    if (stack_counter==0)
    {
     sroot=stackpush(gtemp);
      spriv=sroot;
     stack_counter++;
     }
     else{
     some=cstacknode(gtemp);
      some-&gt;priv=spriv;
      spriv=some;
    }
  
  }
  
  //struct stack is representing a stack
  //struct node is representing a node in graph
  
  snode  cstacknode (graph gtemp)
  //this function should create a node of the stack which should be storing the graph node as a pointer
  {
   snode an;
   an=(snode)malloc(sizeof(snode));
   an-&gt;graph_node=gtemp;
   an-&gt;priv=NULL;
   return an;
  }
  
  void stackpush(snode stemp)
  {
  
  }
  </code></pre>
  
  <p>both the above files are in same directory.
  I compiled the above file stack.c
  <code>cc -I ./ stack.c</code> I following warnings</p>
  
  <pre><code>stack.c:4: warning: ‘stack_counter’ initialized and declared ‘extern’
  stack.c:6: warning: data definition has no type or storage class
  stack.c:6: error: conflicting types for ‘sroot’
  ./declarations.h:21: note: previous declaration of ‘sroot’ was here
  stack.c:6: warning: initialization makes integer from pointer without a cast
  stack.c: In function ‘cstack’:
  stack.c:12: warning: passing argument 1 of ‘stackpush’ from incompatible pointer type
  stack.c:3: note: expected ‘snode’ but argument is of type ‘graph’
  stack.c:12: error: void value not ignored as it ought to be
  stack.c:13: warning: assignment makes pointer from integer without a cast
  stack.c:17: warning: assignment makes pointer from integer without a cast
  stack.c: At top level:
  stack.c:27: error: conflicting types for ‘cstacknode’
  stack.c:17: note: previous implicit declaration of ‘cstacknode’ was here
  stack.c: In function ‘cstacknode’:
  stack.c:32: warning: assignment from incompatible pointer type
  </code></pre>
  
  <p>I want to know when I declared a variable as extern which I have marked bold why do I get that as a warning any thoughts on that and if some one wants to share any other thing on remaining errors then let me know.</p>