If it's c, compile with gcc
typically you use:
Code:
--- sample.h ---
/* just declares the function */
int sample(int x);
-------
--- sample.c ---
/* includes the sample.h header file
this guarantees that the .h and .c file
are coherent */
#include "sample.h"
/* defines the function */
int sample(int x) {
printf("called sample(%d)\n",x);
return 0;
}
-------
--- main.c ---
/* includes the sample.h header file
because it needs the declaration */
#include "sample.h"
/* then uses the function */
int main(int argc, char** argv) {
sample(2);
return 0;
}
-------
Bookmarks