I dimly remember a rule that "No header of the C standard library shall include any other header of the C standard library, except where specifically allowed". But curiously, I couldn't find such a rule written down in C11. I would have expected it in 7.1.2 "Standard headers".
- Is there such a rule in C?
- Is there such a rule in POSIX?
- Is there such a rule in any other standard?
As far as I could see, it is not stated explicitly as permissible (or not). But I believe the possibility is implied by the following passage
When we cross reference this "shall" requirement against its meaning in the conformance section
So if one were to call the
absfunction without includingstdlib.h, the behavior would be undefined. Undefined behavior by its very nature includes the possibility of things "working". And so, if another standard header includesstdlib.hand the program "works", this is inline with the contract stated above.