Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 411
zj_yyzr Avatar asked May 28 '15 10:05

zj_yyzr


People also ask

Should header files be capitalized?

It's a matter of preference. I prefer lowercase for all file names in general including headers because I can avoid using shift when typing their name. "Or it's just that the header files I've seen are named only in lowercase?" - yes.

Should file names be capitalized?

Guidelines for namesMake file and directory names lowercase. Use hyphens, not underscores, to separate words—for example, query-data. html . Use only standard ASCII alphanumeric characters in file and directory names.

Why do we need header files name a few standard header files in C?

Explanation: A header file is generally used to define all of the functions, variables and constants contained in any function library that you might want to use. The header file stdio. h should be used if you want to use the two standard I/O functions printf and scanf.

Why are header guards in all caps?

All caps traditionally is used for macros (defines) so that there's less chance of a name conflict.


1 Answers

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.

like image 193
No-Bugs Hare Avatar answered Sep 19 '22 19:09

No-Bugs Hare