hi lets say you have a big application and you want to break it up to many files... The ideal would be if you can have the application in one .c {i.e main.c} file your types and includes in another file {types.h} and your functions in a seperate file {functions.c} and their declarations in their own header file{i.e. functions.h}.... So we have these files for a simple application:
types.h
//here i would also put all the includes my main application needs
//i am not sure this is a good practise...
//let tA be a seperate type...
typedef int tA;
func.h
#include "func.c"
#ifndef FUNC_H
#define FUNC_H 1
void fadd(tA, tA);
#endif
func.c
void fadd(tA x, tA y)
{
printf("%d\n", x+y);
}
main.c
#include <stdio.h>
#include "func.h"
#include "types.h"
int main()
{
tA a=5;
tA b=6;
fadd(5,6);
return 0;
}
i think that the benefit from this seperation would be:: extra readability + being able to alter the main application without recompiling the functions{just relink them} or alter the functions without recompiling the application{just re-link}....
The problem is that i can't get the seperation to work...and i haven't been able to find a source to address this problem...