The C Standard does make a difference between header and source files referred to by #include
preprocessing directives:
6.10.2 Source file inclusion
Constraints
1 A #include
directive shall identify a header or source file that can be processed by the implementation.
Semantics
2 A preprocessing directive of the form
# include <h-char-sequence> new-line
searches a sequence of implementation-defined places for a header identified uniquely by the specified sequence between the < and > delimiters, and causes the replacement of that directive by the entire contents of the header. How the places are specified or the header identified is implementation-defined.
3 A preprocessing directive of the form
# include "q-char-sequence" new-line
causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the " delimiters. The named source file is searched for in an implementation-defined manner. If this search is not supported, or if the search fails, the directive is reprocessed as if it read
# include <h-char-sequence> new-line
with the identical contained sequence (including > characters, if any) from the original directive.
The compiler may implement a scheme where standard headers are not actually stored as files in the file system. But the directive #include "filename.h"
is specified as searching first for a file in a system specific way, and then searching standard headers as if the directive had been #include <filename.h>
Note that the filename extensions .c
and .h
are purely a convention to distinguish files containing declarations and files containing actual code and data definitions. Nothing in the Standard makes this convention a requirement, beyond the names used for the standard headers. Some people use other conventions with different extensions or no extensions at all for specific needs, but the vast majority of C programmers would regard this as bad practice.
Shafik Yaghmour provided a quote from the C99 Rationale in an answer to a similar question that nails the committees intent on this matter: https://stackoverflow.com/a/27262904/4593267