I'm able to compile the following with no warnings using gcc -c program.c -o program.o
In program.h
#include<math.h>
In program.c
#include<sys/types.h>
#include"program.h"
But not this:
In program.h
#include<sys/types.h>
#include<math.h>
In program.c
#include"program.h"
If done the latter way, I get implicit declarations of all functions called from any libraries included after sys/types.h
. For example:
program.c:352:55: warning: incompatible implicit declaration of built-in function ‘pow’
program.c:352:55: note: include ‘<math.h>’ or provide a declaration of ‘pow’
Why is this?