title: Inline function in header file in C
body: <p>I tried to search a good answer online but fail to get one I can fully understand. Suppose I have a header "add.h":</p>
  
  <pre><code>inline int add(int a, int b){ return a+b; }
  </code></pre>
  
  <p>A file called "adddouble.c":</p>
  
  <pre><code>#include "add.h"
  
  int adddouble(int a, int b){ return 2*add(a,b); }
  </code></pre>
  
  <p>A file called "addsquare.c":</p>
  
  <pre><code>#include "add.h"
  
  int addsquare(int a, int b){ return add(a,b)*add(a,b); }
  </code></pre>
  
  <p>A main file "main.c":</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int adddouble(int, int);
  int addsquare(int, int);
  int main(){
  printf("add double = %d\n", adddouble(10,20));
  printf("add square = %d\n", addsquare(10,20));
  return 0;
  }
  </code></pre>
  
  <p>I use gcc5.2.0 to compile those files, but got: "Undefined symbols for architecture x86_64:". If I add static to inline function in add.h or
  add declaration "extern int add(int, int);" to "adddouble.c", it compiles 
  successfully without errors. I am new to inline function, I don't know how to explain and understand this behaviour. thanks</p>