Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When including header files, is the path case sensitive?

Given this directory tree:

src/MyLibrary/MyHeader.h
src/file.cpp

file.cpp:

#include "mylibrary/myheader.h"
...

Compiling file.cpp works with VS, fails in gcc.

  • What does the standard say?
  • If the path is case sensitive, why is this wise?
  • What's the best practice, keep all file/folder names lowercase and thus do the same when including?

Thanks.

like image 527
Idan K Avatar asked Dec 23 '09 10:12

Idan K


People also ask

Is #include case sensitive?

Both String#includes() and String#indexOf() are case sensitive. Neither function supports regular expressions. To do case insensitive search, you can use regular expressions and the String#match() function, or you can convert both the string and substring to lower case using the String#toLowerCase() function.

Does case matter in Windows path?

Yes. Windows (local) file systems, including NTFS, as well as FAT and variants, are case insensitive (normally).

Is include case sensitive in C++?

C++ is very case sensitive. A #include and #Include Are not the same thing. In fact, #Include does not exist at all. So whether you are creating your own function or using one from a library, check for case sensitivity.

Which file systems are case sensitive?

File names: Traditionally, Unix-like operating systems treat file names case-sensitively while Microsoft Windows is case-insensitive but, for most file systems, case-preserving.


1 Answers

The case sensitivity depends on the Operating System. Windows is not case sensitive. Linux is.

EDIT:

Actually, as observed by Martin York's comment, the case sensitivity depends on the file system. By default Windows uses a case insensitive file system, while Linux uses a case sensitive one. For whoever is interested to know which file systems are case sensitive and which aren't, there is a comprehensive list on Wikipedia: Comparison of file name limitations.

like image 120
Daniel Vassallo Avatar answered Oct 03 '22 22:10

Daniel Vassallo