[A89] Re: HELP! Calling Functions HELP!


[Prev][Next][Index][Thread]

[A89] Re: HELP! Calling Functions HELP!




At 05:55 2001-04-09, you wrote:
>I need to know how to call functions from different c-source files, such
>as function z from file a calling function g from file b!!! I need to
>know now!!! Thanx in advance!!!

What problems do you have?
declare the function g at the top of file a too, like this or something:

void g(int x, char y); <-- note that ;...

(actual declaration ofcourse depends on what parameters your function g 
takes, and what it returns)
then use wherever you want in file a, and the linker will take care of the 
rest.

The goodlooking way is to put thoose declarations in a file called b.h and 
#include "b.h" in a.c
(function definitions in b.c still ofcourse)
I have heard of people using #include to include .c-files too, that is not 
really good.
Then you don't get the full benefit of using multiple files, since the 
whole will have to be compiled everytime, and not just the files that are 
updated.

hope that helps, if not, ask again with more detail :)
///Olle





References: