Common Header Files

Started by
3 comments, last by Oluseyi 15 years, 3 months ago
Why do some header files not have an extension ".h"? For example, the header file for file streaming is just "fstream" not "fstream.ext" where 'ext' is any extension.
Advertisement
Those are template files. They usually don't have an extension to remind the programmer that they can behave differently than a header.
Quote:Original post by Nypyren
Those are template files. They usually don't have an extension to remind the programmer that they can behave differently than a header.

Incorrect. cmath, cstdlib, ctypes?

All header files in C and C++ had .h extensions prior to the standardization of C++. When C++ was standardized in 1997, the new standard library headers dropped the .h prefix to distinguish them from the pre-standard versions, and then libraries brought over from C had a 'c' prepended to their names. So, for example, fstream.h and iostream.h became fstream and iostream, respectively, while math.h, stdlib.h and stdio.h became cmath, cstdlib and cstdio.
Ah, that's good to know. In console game programming, we're typically stuck with SDKs and engines that are still written in the same fashion as 15 years ago, which still include all of the .h extensions. Literally the *only* time I've ever seen a header without an extension was with very new (VS.Net+) implementations of STL.

Stuck with old-style SDKs for the console, and a wholesale switch to C# on PCs, you can imagine how rarely I've seen them without ".h".
Quote:Original post by Nypyren
Ah, that's good to know. In console game programming, we're typically stuck with SDKs and engines that are still written in the same fashion as 15 years ago, which still include all of the .h extensions.

Having an .h extension is not a sign of archaism. The lack of extensions only applies to headers from the C++ Standard Library. Just wanted to clarify that, because the language above suggests a little confusion. Modern C++ libraries and SDKs have .h extensions.

Those headers can be interesting to read through. Scary, but still interesting. [smile]

This topic is closed to new replies.

Advertisement