B
BartC
Jens Schweikhardt said:BartC <[email protected]> wrote
# I'm not sure it's even possible, because of the mutual or circular
# dependencies I mentioned.
You can't have circular include dependencies, no matter what rule
you follow. In the end, all identifiers must be declared/defined
before use (modulo some esoteric situations like tag names in
prototype scope).
Suppose you have two silly modules like a.c and b.c here:
//--a.c-----------------------
#include <stdio.h>
#include "b.h"
void function_a(float x) {
printf("%f\n",x);
}
int main(void) {
function_b(56);
}
//----------------------------
//--b.c-----------------------
#include <stdio.h>
#include "a.h"
void function_b(float x) {
function_a(x);
}
//----------------------------
with their respective header files:
//--a.h-----------------------
void function_a(float);
//----------------------------
//--b.h-----------------------
void function_b(float);
//----------------------------
What is the module hierarchy here? Now a.c contains main(), so that might be
considered the root, but then b.c also depends on a.c. You can't have one
without the other. And without an obvious external entry point such as
main(), a.c and b.c could have the same hierarchical status.