title: warning in extern declaration
body: <p>I declared a variable i in   temp2.h
   <code>extern i;</code>  which contains just one above line
  and made another file
  temp3.c</p>
  
  <pre><code> #include&lt;stdio.h&gt;
  #include&lt;temp2.h&gt;
  int main ()
  {
  extern i;
  i=6;
  printf("The i is %d",i);
  }
  </code></pre>
  
  <p>When I compiled above as
   <code>cc -I ./ temp3.c</code>   I got following errors</p>
  
  <pre><code> /tmp/ccJcwZyy.o: In function `main':
  temp3.c:(.text+0x6): undefined reference to `i'
  temp3.c:(.text+0x10): undefined reference to `i'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I had declared extern in temp3.c above as K R page 33 says as I mentioned in above post.
  I tried another way for temp3.c with same header file temp2.h</p>
  
  <pre><code> #include&lt;stdio.h&gt;
  #include&lt;temp2.h&gt;
  int main ()
  {
  
  i=6;
  printf("The i is %d",i);
  }
  </code></pre>
  
  <p>and compiled it  <code>cc -I ./ temp3.c</code>   and got following error</p>
  
  <pre><code>/tmp/ccZZyGsL.o: In function `main':
  temp3.c:(.text+0x6): undefined reference to `i'
  temp3.c:(.text+0x10): undefined reference to `i'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I also tried</p>
  
  <pre><code> #include&lt;stdio.h&gt;
  #include&lt;temp2.h&gt;
  int main ()
  {
  extern i=6;
  printf("The i is %d",i);
  } 
  </code></pre>
  
  <p>compiled this one</p>
  
  <pre><code> cc -I ./ temp3.c
  </code></pre>
  
  <p>got same error as in post 1</p>
  
  <pre><code> temp3.c: In function ‘main’:
  temp3.c:5: error: ‘i’ has both ‘extern’ and initializer
  </code></pre>
  
  <p>So I have tried at least 3 different ways to use extern but non of them worked.</p>