C++ Include Guards for Standard Headers

后端 未结 4 1731
悲哀的现实
悲哀的现实 2021-01-13 00:36

I am wondering if/ what include guards on files like windows.h, math.h, iostream, stdio... etc.

Since I have thos

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-13 01:36

    The C++ standard requires that the headers be organized such that you can include any of them multiple times, directly or indirectly, without running into problems. It doesn't mandate how that result will be achieved, just that it shall be achieved.

    ISO/IEC 14822:2011

    17.6.2.2 Headers [using.headers]

    ¶2 A translation unit may include library headers in any order (Clause 2). Each may be included more than once, with no effect different from being included exactly once, except that the effect of including either or depends each time on the lexically current definition of NDEBUG.178

    178 This is the same as the Standard C library.

提交回复
热议问题