When Including Header Files, Is the Path Case Sensitive

When including header files, is the path case sensitive?

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.

Case Sensitivity in C++ Header Files

Case sensitivity in header names and include directives is implementation defined. Generally it works out to whether the platform you're building on is case sensitive or not.

I'd have to test to make sure, but I suspect that if you type any variety of 'xinput.h' it will find the the one that occurs first in the header search paths, even if the file that occurs later in the search paths is a better match in terms of case. This would be quite unintuitive from the perspective of a developer not familiar with these issues, because it would mean that you could use one of those auto-completions, and VS would then include the file not selected.

It's also possible that VS is smarter than that and will search for the best case match.

How to force Visual Studio preprocessor case sensitivity with #includes?

You can't, because the Windows file system is itself case-insensitive.

If you could get into a situation where you had both RICHIE.h and richie.h, it might make sense to control case sensitivity, but you can't.

Porting C++ code from Windows to Linux - Header files case sensitivity issue

You're out of luck on your preference. Linux is case-sensitive, and always will be. Just identify the names that need to be changed, and sed away.

Is there a method to ignore the file name case senstivity in Qt c++?

Windows already ignores case sensitivity, so you don't have to do anything to ignore it as long as you execute your code on Windows.

The problem is when you need to make the difference between two paths relying on the case sensitivity. You really should avoid to have files with the same name in the same directory.

Is there a way to make Visual Studio case sensitive on includes?

Case sensitivity doesn't depend on the compiler, but the
underlying file system. So Linux may not be case sensitive, if
the file system is remotely mounted on a Windows box, and vice
versa. If you want to force case sensitivity on a Windows box,
the only solution I know is to remote mount a file system on
a Unix box.

Note that this shouldn't be a problem if you're developing on
Linux, then moving to Windows. It's the reverse which is
a problem. And the only real solution is to define and strictly
enforce a naming convention. You need it for the code anyway
(since C++ is case sensitive regardless). So if you have
a class FxTrade, your coding conventions should insist that it
is Fx, and not FX; these convensions must be enforced in the
C++ code, or you'll go nuts having to look up each time which
one it is, and the same code review that enforces them in the
source should enforce them in the file names.

(And for what it's worth, it's a real pain to fix such an error
under Subversion, since svn FXTrade.cpp FxTrade.cpp doesn't
work under Windows; you have to move it to some other name, then
commit, and then move it to the name you want.)

What are the benefits of a relative path such as ../include/header.h for a header?

I prefer the path syntax as it makes it very clear what namespace or module the header file belongs to.

#include "Physics/Solver.h"

Is very self-describing without requiring every module to prefix their name to header files.

I almost never use the ".." syntax though, instead I have my project includes specify the correct base locations.

File paths in Windows environment not case sensitive?

Yes. Windows (local) file systems, including NTFS, as well as FAT and variants, are case insensitive (normally). The underlying implementation of a network file system may be case sensitive, however, most software that allows Windows to access it (such as SMB) will automatically make case sensitive file systems appear as case insensitive to Windows.

For details, I'd read the section in the Wikipedia article on filenames.



Related Topics



Leave a reply



Submit