Why people don't use uppercase in the name of header files in C++?

zj_yyzr picture zj_yyzr · May 28, 2015 · Viewed 9.5k times · Source

I was wondering why people don't use uppercase in name of header files. I see many header files with name only in lowercase. But I thought it would be more easy to read if they write them with uppercase, say "BaseClass.h", "SubClass.h", instead of "baseclass.h", "subclass.h". Why is that? Or it's just that the header files I've seen are named only in lowercase?

Answer

No-Bugs Hare picture No-Bugs Hare · May 28, 2015

There are systems out there which are case-sensitive (*nix), and there are systems which are traditionally case-insensitive (Windows).

As a result, if you develop on *nix and create two files: baseclass.h and BaseClass.h - your code will compile fine on *nix, but when moving it to Windows, it won't even unpack there properly.

On the other hand, if you develop on Windows and have file BaseClass.h while writing '#include "baseclass.h"' - it will compile on case-insensitive Windows, but will fail to compile on *nix.

To avoid these troubles, there is an unwritten (I think) convention of using all filenames in lowercase - at least it is guaranteed to work the same way everywhere. Kind of the least common denominator approach, which doesn't cause too much inconvenience.