Question

I'm a complete noob when it comes to C++ and I've been hacking away on Moai trying to add support for an Xbox 360 gamepad via XInput. When I include the header for XInput there are two options:

  1. XInput XInput

and

  1. Xinput Xinput

Further, in order to use XInput I need to include windows.h. All the examples I've seen use the following syntax:

#include <windows.h>

But the auto complete in Visual C++ Express 2010 inserts

#include <Windows.h>

Windows.h

In the case of XInput/Xinput it seems that case-sensitivity matters but in the case on Windows.h it does not seem to matter.

Does case-sensitivity matter when including header files? Is there some logic to this?

Is the XInput difference simply a matter of there being a header for something called XInput and another something called Xinput?

Was it helpful?

Solution

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.

OTHER TIPS

It only matters if the underlying file system is case sensitive. The Windows filesystem is not case-sensitive, but the file systems of operating systems like Linux are. Try to use the exact actual name of the real file to ensure that your code works if/when you port it from one OS to another.

On Windows, filenames are not case-sensitive, and this extends to #include. Any case will do.

On some platforms (e.g. Linux), filenames are case-sensitive, so you would need to match the actual filename.

Windows is not case sensetive as others have said. But that's not your problem. Your problem is with include-file settings in Visual Studio. The compiler will look for standard headers (header inclusion using <> syntax), in the order they are setup. Launch Tools->Options, and then lookup Projects and Solutions->VC++ directories and see the sequence of Include Files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top