title: How to design the interface for a static library in C
body: <p>Although I am not an experienced programmer in C, I have to use this language at work to build a static library which compiles both on SunOS and Win32. This library has just a few source files and their correspondent headers (let's say: <code>a.c</code>, <code>b.c</code>, <code>a.h</code> and <code>b.h</code>). The project compiles in both platforms and the library <code>mylib.a</code> is generated.</p>
  
  <p>My problem is how to expose the implemented functions of <code>mylib.a</code> to other projects, because when I add both <code>a.h</code> and <code>b.h</code> I get some macro redefinition errors.</p>
  
  <p>EDIT: I found that the macro redefinition error was because of a macro definition into the compilation command (not related to my headers) and it is solved :) But still I would like advice on organizing my source and header files.</p>
  
  <p>My doubt is whether I modify <code>a.h</code> and <code>b.h</code> to be used externally or if I should create a header file specifically for declaring the interface of this library (let's say <code>mylib.h</code>). I would not like to overcomplicate the original headers, but I would not like to have to keep a different header in sync ... I would like to hear from more experienced C programmers about their patterns, advantages of each approach and whether there are other options.</p>
  
  <p>Thank you in advance.</p>
  
  <p>EDIT: seems I have not provided enough information; the schema below tries to show how my files are organised: each code file only includes its header, each header has a guard condition, each header includes a common header, this common header includes all headers.</p>
  
  <pre><code>// a.c ----
  #include "a.h"
  
  // b.c ----
  #include "b.h"
  
  // a.h ----
  #ifndef GUARD_A_H
  #define GUARD_A_H
    # include "liball.h"
    void function_prototypes_implemented_in_a();
  #endif // GUARD_A_H
  
  // b.h ----
  #ifndef GUARD_B_H
  #define GUARD_B_H
    # include "liball.h"
    void function_prototypes_implemented_in_b();
  #endif // GUARD_B_H
  
  // liball.h ----
  #ifndef GUARD_LIBALL_H
  #define GUARD_LIBALL_H
    # include &lt;time.h&gt;   // standard headers
    # include &lt;stdioa.h&gt;
  
    # include "a.h"      // all headers in this project
    # include "b.h"
  #endif // GUARD_LIBALL_H
  </code></pre>