Can a C implementation implicitly include standard headers when another header is included?

When reading Is this the correct C declaration? If so, then why is this not working? I'm thinking of

#include <stdio.h> int main(void) { int bool = 0; return bool == 0; } 

Is this program strictly appropriate? In other words, is stdio.h allowed to include stdbool.h or is it prohibited? Is this indicated by the specification?

+6
source share
2 answers

Standard C headers cannot include other headers. This is different from C ++ where it is explicitly allowed.

C99 Standard, Section 7.1.3

Each header declares or defines all identifiers listed in the corresponding subparagraph [...] No other identifiers are reserved.

+5
source

I'm not sure how authoritative this is, but here is what Plauger says (provided for c89).

The Standard C library provides 15 standard headers. Headers have several properties

They are mutually independent. The standard header does not require that another standard header must be included in order to work properly. The standard header does not include another standard header .

I cannot find mention of this in c99 or c89.

EDIT

I see inttypes.h includes stdint.h

7.8-1

The <inttypes.h> header includes the <stdint.h> header and extends it with additional features provided by hosted implementations.

+3
source

Source: https://habr.com/ru/post/892755/


All Articles