title: Linking .h files with .c with #ifdef header guards
body: <p>im having trouble linking .h and .c files, i've also read some threads regarding this problem and all of them is a bit vague and still i can't fully grasp the concept of it, and im having a lot of linking problems, <strong>Say i have b.c and b.h which i will use in a.c</strong>, and im confused whether to include b.h both a.c and b.c cuz b.c itself needs to know the structure defined in b.h, i have some function which has its prototype in b.h and is defined in b.c which also use the structure in b.h, im am not including b.h in b.c cuz as what i know b.h is more like an interface to a.c which will use the functions in b.c... Here a more clear example</p>
  
  <p><strong>b.h file</strong></p>
  
  <pre><code>typedef struct{
  int x, y;
  }myStruct;
  
  void funct1(myStruct);
  void funct2(myStruct);
  </code></pre>
  
  <p><strong>b.c file</strong></p>
  
  <pre><code>void funct1(myStruct x)
  {
      //do something
  }
  
  void funct2(myStruct y)
  {
       //do something
  } 
  </code></pre>
  
  <p><strong>a.c file</strong></p>
  
  <pre><code>#include "b.h"
  
  int main()
  {
  myStruct x;
    funct1(x);
    funct2(y);
  return 0;
  }
  </code></pre>
  
  <p>Executed the command in cygwin: <strong>gcc b.c a.c -g</strong></p>
  
  <p>Now the confusing part, i have a linking error wherein when b.c is compiled it can't detect the structure and the prototypes in b.h. Cuz all i know is that b.h is used to link b.c from a.c but when both .c is compiled it seems that b.c can't find its strucutre and prototypes, </p>
  
  <p><strong>Why didn't i include b.h in b.c?</strong> 
  <strong>Answer</strong>: Cuz as what i know, b.h is already included in a.c and when i include it again in b.c, i'll be doing double inclusions &lt;--- thats what i learn so far and i know there is #ifdef but it seems it won't work, maybe i still don't know how to use it, if you know please feel free to discuss this.</p>
  
  <p>If you have any idea as to how to go about this feel free to tell me some.</p>
  
  <p>there is a #ifdef directive but i can't seem to have any idea how to do this. </p>
  
  <p>NOTE: ASSUME THAT ALL ABOVE CODES IS SYNTACTICALLY CORRECT if there are any misspelled word please ignore, i'm only after the inclusions between .h and .c</p>