Header file that includes all standard C library headers The Standard C Library consists of various headers files.  Often only a few select ones are needed for given code.

Other times it is simply convenient coding to include them all in a .c file, even if that make the compilation time a bit slower.

Including all standard &lt;*.h&gt; is useful to help detect naming collisions of a .c file with an existing standard function, object, type, macro, etc.

Review Goal

How well does std.h accomplish the goal of including all standard header files via one .h file given that the set varies amongst C versions and implementations?

/*
 * std.h
 *  Created on: Mar 16, 2019, Author: chux
 */

#ifndef STD_H_
#define STD_H_

#include &lt;assert.h&gt;
#include &lt;ctype.h&gt;
#include &lt;errno.h&gt;
#include &lt;float.h&gt;
#include &lt;limits.h&gt;
#include &lt;locale.h&gt;
#include &lt;math.h&gt;
#include &lt;setjmp.h&gt;
#include &lt;signal.h&gt;
#include &lt;stdarg.h&gt;
#include &lt;stddef.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;time.h&gt;

#if defined __STDC__ &amp;&amp; defined __STDC_VERSION__

#if __STDC_VERSION__ &gt;= 199409
#include &lt;iso646.h&gt;
#include &lt;wchar.h&gt;
#include &lt;wctype.h&gt;
#endif

#if __STDC_VERSION__ &gt;= 199901
#ifndef __STDC_NO_COMPLEX__
#include &lt;complex.h&gt;
#endif
#include &lt;fenv.h&gt;
#include &lt;inttypes.h&gt;
#include &lt;stdbool.h&gt;
#include &lt;stdint.h&gt;
#include &lt;tgmath.h&gt;
#endif

#if __STDC_VERSION__ &gt;= 201112
#include &lt;stdalign.h&gt;
#ifndef __STDC_NO_ATOMICS__
#include &lt;stdatomic.h&gt;
#endif
#include &lt;stdnoreturn.h&gt;
#ifndef __STDC_NO_THREADS__
#include &lt;threads.h&gt;
#endif
#include &lt;uchar.h&gt;
#endif

#if __STDC_VERSION__ &gt;= 201710
/* None added */
#endif

#endif

#endif /* STD_H_ */




In making a set of functions and types called say foo, I do not recommend including all header files in a foo.h, yet perhaps in foo.c.

Sample usage

// foo.h  (no std.h here)
#ifndef FOO_H_
#define FOO_H_

#include &lt;stdint.h&gt;
#include &lt;time.h&gt;

typedef struct {
    time_t t;
    uint32_t u32;
} foo;

void foo_this(foo *f);
void foo_that(foo *f);

#endif /* FOO_H_ */


foo.c or main.c

#include "foo.h"
#include "std.h"

int main(void) {
  foo f;
  foo_this(&amp;f);
  foo_that(&amp;f);
  printf("Hello World!\n");
  return 0;
}




The alternative spellings afforded in &lt;iso646.h&gt; seem to be a solution to a regional character set problem of years ago.  I reluctantly included &lt;iso646.h&gt; here but do see that a good candidate to exclude.  It defines macros for and, or, xor and others.
With this suggested usage:


#include "foo.h"
#include "std.h"



then any macros defined in "std.h" (and not used in the rest of the main) won't break the program.  Swapping these round:

#include "std.h"
#include "foo.h"


solves that problem, but then fails to diagnose missing includes in "foo.h".