title: Defining external function (module) in the header file in C
body: <p>When I compile the program, outlined below, I am getting the following error(s) back</p>
  
  <pre><code>[igor@localhost ~/I2C]$ make i2c_VIPER DEFINE=-DVIPER
  gcc -g -Wall -D__USE_FIXED_PROTOTYPES__ -DVIPER -ansi -lusb   -c -o i2c.o i2c.c
  In file included from i2c.c:9:
  viperboard.h:120: error: expected ‘)’ before ‘*’ token
  i2c.c: In function ‘main’:
  i2c.c:32: error: ‘usb_dev’ undeclared (first use in this function)
  i2c.c:32: error: (Each undeclared identifier is reported only once
  i2c.c:32: error: for each function it appears in.)
  i2c.c:33: warning: implicit declaration of function ‘i2c_VIPER’
  make: *** [i2c.o] Error 1
  </code></pre>
  
  <p>I've tried many things,  more or less semi-blindly,  to make it working. The <code>struct parsed_CLI_I2C_t</code> defined by me, works flawlessly. No compilation errors. But, when I try to use <code>struct usb_device</code> from <code>&lt;usb.h&gt;</code> in equivalent way, the compiler is not happy. 
  What I am doing wrong ?</p>
  
  <p>Relatively detailed description follows.</p>
  
  <p>Let's start with a code snippet from the standard <code>#include</code> &lt; <a href="http://www.libusb.org/browser/libusb-compat-0.1/libusb/usb.h/" rel="nofollow" title="&lt;usb.h&gt;">usb.h</a> > &lt;-- link to the full header file </p>
  
  <pre><code>/* Data types */
  struct usb_device;
  struct usb_bus;
  
  struct usb_device {
    struct usb_device *next, *prev;
  
    char filename[PATH_MAX + 1];
  
    struct usb_bus *bus;
  
    struct usb_device_descriptor descriptor;
    struct usb_config_descriptor *config;
  
    void *dev;        /* Darwin support */
  
    u_int8_t devnum;
  
    unsigned char num_children;
    struct usb_device **children;
  };
  </code></pre>
  
  <p>Here is the first local header file #include "viperboard.h"</p>
  
  <pre><code>struct parsed_CLI_I2C_t;
  extern int  i2c_VIPER (struct usb_device **usb_dev, struct parsed_CLI_I2C_t **CLI_I2C_options);
  extern bool OpenDevice(void);
  </code></pre>
  
  <p>This is the second local header file  #include "I2C.h"</p>
  
  <pre><code>typedef struct 
  {
     char  *USB_board; 
     int    query;
     int    write_type;
  } parsed_CLI_I2C_t;
  
  extern int  parse_CLI_I2C_options (int argc, char *argv[], parsed_CLI_I2C_t **CLI_I2C_options);
  </code></pre>
  
  <p>The main program looks like this </p>
  
  <pre><code>/* all other standard include stuff skipped for brevity */
  #include &lt;usb.h&gt;
  #include "viperboard.h"
  #include &lt;stdbool.h&gt;
  
  #include "I2C.h"
  
  int main(int argc, char *argv[])
  {
     parsed_CLI_I2C_t *CLI_I2C_options;
     parse_CLI_I2C_options (argc, argv, &amp;CLI_I2C_options);
  
     struct usb_device *usb_dev; 
     i2c_VIPER (&amp;usb_dev, &amp;CLI_I2C_options);
  }
  </code></pre>
  
  <p>and, finally, this is the external module </p>
  
  <blockquote>
    <p>i2c_VIPER.c</p>
  </blockquote>
  
  <pre><code>/* all other standard include stuff skipped for brevity */
  #include &lt;usb.h&gt;
  #include "viperboard.h"     
  #include &lt;stdbool.h&gt;
  
  #include "I2C.h"
  
  int  i2c_VIPER (struct usb_device **usb_dev, struct parsed_CLI_I2C_t **CLI_I2C_options )
  {
     bool   connected;         /* True if the ViperBoard is connected */
  
     connected = OpenDevice();
  
     return(0);
  }
  </code></pre>
  
  <p>This is </p>
  
  <blockquote>
    <p>OpenDevice.c</p>
  </blockquote>
  
  <pre><code> #include &lt;stdbool.h&gt;
   #include &lt;usb.h&gt;
  
   bool OpenDevice()  /* &lt;----  this is line 11 */ 
   {
       usb_set_debug( 0 );
  
       /* Initialize USB library */
       usb_init( );
  
       etc etc etc 
  
       return true;
   }
  </code></pre>
  
  <p>========================================================
  30 minutes later: all suggested changes implemented
  Another type of error appeared.</p>
  
  <pre><code> OpenDevice.c:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘OpenDevice’
  make: *** [OpenDevice.o] Error 1
  </code></pre>