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

后端 未结 5 1075
一生所求
一生所求 2021-02-14 03:38

If you have a header file named ThisIsAHeaderFile.h, the following will still locate the file in Visual Studio:

#include 
5条回答
  •  广开言路
    2021-02-14 04:19

    I would like to point out that this is not an unsolvable problem as many tries to point out to the OP. The case insensitivity is beside the point. The point is as Lorenz03Tx explains in a comment, even though the file system is case insentitive the case is retained, so it can be controlled.

    Such a counter measures is really great to have when doing cross platform development, and prevents much after work when the code is compiled for the other platform. Not to forget that making the build process more picky you would induce better habits for the developers, as they gradually will be more consistent how they include and name files.

    TL;DR

    One solution is to use a script that simply scans the source files for include statements and tries to match them along the include paths. Such a script could be added to visual studio post-build events, and thus run at every build, or (inspired by krlmlr) use the preprocessor of a compiler that enforce case sensitivity.

提交回复
热议问题