2

I have a file called Time.h in a folder (src) that is included in the additional include directories/compiler include paths. Including "Time.h" is fine, but when including , Visual Studio seems to get confused and I get upwards to 100 errors before VS stops compilation in all files from filesystem to chrono saying some standard macro is undefined. No error about ambiguity. Is this because of Windows' case insensitivity? In that case, how can it be avoided other than making a dedicated directory Time/Time.h?

  • 2
    This is a limitation being imposed by the Windows operating system, not the C++ language. The filesystem preserves case when you name a file, but treats file lookup as case-insensitive. https://stackoverflow.com/questions/7199039/file-paths-in-windows-environment-not-case-sensitive – jxh Nov 06 '19 at 18:12
  • Also, you can change your filesystem to be case sensitive (but at the risk of breaking some applications still using legacy code): https://www.howtogeek.com/354220/how-to-enable-case-sensitive-folders-on-windows-10/ – jxh Nov 06 '19 at 18:13
  • 1
    *I have a file called Time.h in a folder (src)* -- The lesson learned is that you shouldn't name your header files the same as standard ones. – PaulMcKenzie Nov 06 '19 at 18:19
  • To avoid name clashes keep your names different from those of the library. – Itachi Uchiwa Nov 06 '19 at 18:19
  • @jxh It's per-directory – Lightness Races in Orbit Nov 06 '19 at 18:25
  • @LightnessRaceswithMonica: True! But, you can traverse all directories and execute the command with a batch script, I think... https://stackoverflow.com/questions/25691158/recursively-execute-command-in-all-directories-using-windows – jxh Nov 06 '19 at 18:40
  • @jxh You could, but what I'm saying is that setting this switch on your project directory won't automatically affect any other applications still using legacy code. You'd have to go out of your way to do that (like in the manner you describe) – Lightness Races in Orbit Nov 06 '19 at 18:44

1 Answers1

2

Is this because of Windows' case insensitivity?

Yes.

In that case, how can it be avoided other than making a dedicated directory Time/Time.h?

It can't, except by using a directory, or choosing a different name for the file.

Well, technically, you can make NTFS directories case sensitive. However, this seems like a fragile and non-portable solution, and I cannot guarantee that Visual Studio itself will honour it.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055