title: C - Include only specific function
body: <p>Alongside <code>main.c</code> file, I have following <code>my_custom_data_structure.c</code> file in my project. My <code>my_custom_data_structure.c</code> file contains a lot of variables, functions, etc.</p>
  <p>I am using <code>#include &quot;my_custom_data_structure.c&quot;</code> directive in <code>main.c</code>.</p>
  <h1>Problem</h1>
  <p>I would like to import only single function called <code>foo</code> from <code>my_custom_data_structure.c</code>. I don't need all the variables and functions, which are declared in <code>my_custom_data_structure.c</code> file.</p>
  <p>Any insights appreciated.</p>
  <h1>File structure</h1>
  <pre><code>-
  |- main.c
  |- my_custom_data_structure.c
  </code></pre>
  <h1>Content of my_custom_data_structure.c</h1>
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  
  
  int DELAY = 20;
  
  int SPEED = 7;
  
  char GRANULARITY_CHAR = 'g';
  
  unsigned int RANGE = 3;
  
  
  void foo(){
      // TODO: In future, this function will print SPEED.
      printf(&quot;foo works!&quot;);
  }
  
  /*
      The rest of this file is filled by a lot 
      of code, which is not needed for main.c
  */
  </code></pre>
  <h1>Content of main.c</h1>
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  #include &quot;my_custom_data_structure.c&quot;
      
  int DELAY = 3;
      
  int main(){
      foo();
      printf(&quot;Delay is %d&quot;, DELAY);
      return 0;
  }
  </code></pre>
  <p><strong>UPDATED</strong>: Added working example</p>