Why not all the standard headers are preceded with std
prefix? I.e. why complex.h
and not stdcomplex.h
?

- 5,392
- 4
- 17
- 36
-
8Because no one said they must ♂️ – Eugene Sh. Feb 25 '21 at 17:18
-
For historical reasons. The first C compiler was in the 1970s, and at that time without standards. – Basile Starynkevitch Feb 25 '21 at 17:40
-
Consider memory cost $1/byte circa 1970 set the precedent for terse names. – chux - Reinstate Monica Feb 25 '21 at 18:01
-
Using `<` and `>` in `#include` instead of `"` and `"` sufficed to distinguish “system” headers from “user” headers. The name space of “system” headers was sufficiently uncluttered that early versions of the C standard did not need to use additional methods to distinguish standard headers. – Eric Postpischil Feb 25 '21 at 18:18
-
1The standard header names need to conform to the restrictions in the standard (6.10.2/5), and `stdcomplex.h` is too long. – Ian Abbott Feb 25 '21 at 19:04
-
2@IanAbbott: 6.10.2 5 does not impose restrictions on header names. It permits C implementations not to distinguish header names based on characters beyond the eighth before the `.` (or that have characters other those indicated or that start with a digit). As long as the header names are distinguishable by their first eight characters, they are okay. The standard library includes header names longer than eight characters, `stdatomic.h` and `stdnoreturn.h`. – Eric Postpischil Feb 25 '21 at 21:16
-
@EricPostpischil Good point. – Ian Abbott Feb 26 '21 at 09:14
-
@chux-ReinstateMonica I think Dennis Ritchie said somewhere that source code space was never something taken in consideration when C was designed. I can't find the source for that rumour though. – Lundin Feb 26 '21 at 09:32
2 Answers
Why? why not? Who knows? The header files that make up the standard libraries began evolving into that category before a standard existed, over years of revisions by developers and scrutiny by C committee members. Many of the original authors and committee members who developed and canonized these files are now part of the big compiler in the sky and not available to answer the question "why" the standard naming convention is not really conventional or standard. But reading this wiki page on the topic may at least allow you to get a little history and context.

- 22,849
- 3
- 43
- 87
The naming has historically nothing to do with formal ISO standardization and I don't think there ever was an ambition to toss std
in front of everything standard library.
Earliest mention of a standard library seems to be K&R The C programming Language 1st edition from 1978, where below chapter 8.5 we can read:
The data structure that describes a file is contained in the file
stdio.h
, which must be included (by#include
) in any source file that uses routines from the standard library.
Notably K&R refers to it as the standard library, not the standard input/output library. So maybe (and this is speculation) this header was originally intended to be the whole standard library for C. This is the only one of the current ISO standard library headers I can find mentioned in the book and it pre-dates formal standardization by more than ten years.
Then later during ANSI/ISO standardization the headers stdarg
, stddef
, stdio
and stdlib
were added to the first standard, but these are just 4 out of 15 standard headers using the std prefix. Various C or Unix de-facto standard headers just got added to the standard pretty much arbitrary. There was no sound rationale for anything, least of all API or naming. They just tossed in various already present "good to have" Unix libs into the standard.
Notably, the original C standard only guaranteed 6 unique letters for standard headers and all the original headers have names with 6 or less letters. This was expanded to 8 letters in C99.
C99 continued the tradition of arbitrary naming, adding a whole bunch of new headers, of which only stdint
and stdbool
have the std prefix. That C11 named most new headers with std prefix might be some influence from C++, but notably C11 also added uchar.h
without prefix.

- 195,001
- 40
- 254
- 396