In the example of a transitive dependency on the preprocessor page, the error when #include <string.h> is removed from b.h is:
$ clang -o main main.c a.c b.c
main.c:2:3: warning: implicit declaration of function 'printf' is invalid in C99 [-Wimplicit-function-declaration]
1 warning generated.
/usr/bin/ld: /tmp/main-3866ce.o: in function `main':
main.c:(.text+0x20): undefined reference to `printf'
This is then resolved by adding a #include <string.h> to main.c. However, the C standard library declares printf() in <stdio.h>, not<string.h>. I'm not sure what C library you are using that includes a declaration of printf() when including <string.h>, but that is arguably another instance of a transitive dependency in itself.
I suggest you use a different function, header, or combination in your example.
In the example of a transitive dependency on the preprocessor page, the error when
#include <string.h>
is removed fromb.h
is:This is then resolved by adding a
#include <string.h>
tomain.c
. However, the C standard library declaresprintf()
in<stdio.h>
, not<string.h>
. I'm not sure what C library you are using that includes a declaration ofprintf()
when including<string.h>
, but that is arguably another instance of a transitive dependency in itself.I suggest you use a different function, header, or combination in your example.