This question concerns the various types that need to be defined in the required headers of the POSIX/SUS standard.
Some types needs to be defined in many header files, and I'm wondering what's the correct and compliant way of achieving this.
For instance, look at the <time.h>
header specification:
Inclusion of the header may make visible all symbols from the <signal.h> header.
This is straightforward, <signal.h>
is included from <time.h>
.
Now what about this:
The clock_t, size_t, time_t, clockid_t, and timer_t types shall be defined as described in <sys/types.h>.
As I understand it, it means we can't simply include <sys/types.h>
from <time.h>
, as this would expose more symbols than required.
So can anyone confirm this?
Would it break the standard compliance to include <sys/types.h>
?
If so, I think the best solution is to create a specific header for each type, so a particular type can be made visible from anywhere, without worrying about other symbols.
Is there any other good solution?
And last thing, what about the types from the C standard?
Lots of types in the POSIX/SUS specification are integral types, and may need to have fixed width.
So would it be ok for the standard to include <stdint.h>
from a specific header, or would it break the compliance?