x.h file definition in y.c file. how to link?
as the title says..
if I create a header file with name MyHeader.h and its corresponding definitions in different file MyFunction.c
or even general case.. I have those function definitions in multiple .c files..
how will the compiler know where the definition of a particular declaration is?
Ex:
MyHeader.h
Code:
#ifndef __MYHEADER_H
#define __MYHEADER_H
void f1(void);
void f2(void);
#endif
f1.c
Code:
void f1(void)
{
printf("I am f1");
}
f2.c
Code:
void f2(void)
{
printf("I am f2");
}
test.c
Code:
#include "MyHeader.h"
int main()
{
f1();
f2();
return 0;
}
how should be the Makefile now?