开发者

Can a C implementation implicitly include standard headers when including a different header?

While reading Is this proper C declaration? If so, why doe开发者_Python百科s it not work? I was thinking about

#include <stdio.h>

int main(void) {
  int bool = 0;
  return bool == 0;
}

Is this program strictly conforming? In other words, is stdio.h allowed to include stdbool.h or is it forbidden to do so? Is this specified by the spec?


C standard headers can not 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 its associated subclause[...] No other identifiers are reserved.


I'm not sure if it's authoritative in any way, but here's what Plauger says (granted it's for c89).

The Standard C library provides fifteen standard headers. The headers have several properties

They are mutually independent. No standard header requires that another standard header be first included for it to work properly. Nor does any standard header include another standard header.

I can't find any mention of this in c99 or c89.

EDIT

I can see inttypes.h includes stdint.h

7.8-1

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜