As far as I know (and this is what I've used)
If you wish to use a function from a .c (or its correspond header) file that
isn't included in the .c file you wish to use the function in all yo have
to do is declare the prototype as external.
eg.
--------
magic.c
..
int i_want_this_function(int some_parameter)
{
...
}
-------
newfile.c
#include <all headers except magic.h (which deosnt exist)>
/* declared globally any function can see the external function */
extern int i_want_this_function(int some_parameter);
void new_function(int some_parameter)
{
/* or declared locally only this function can see it */
extern int i_want_this_function(int some_paramater);
int blah
blah = i_want_this_function(30);
}
Note that you only need one of the extern prototypes above, but I find
its best to make them global just in case I need them somewhere else in
the file.
This should work fine. And it means you dont always have to have header
files.. although I must admit sometimes its hard to know where the
original full declaration of an extern function is :) Thank goodness for
grep ;)
Ted (ok, the names Greg, but who cares right :P ).
This archive was generated by hypermail 2b30 : 12/18/00 PST