Visual Studio (C++)- what is the best practice regarding directories configurations?

Let's consider first only include paths.

The Microsoft documentation states that the compiler searches for directories in the following order:

  1. Directories containing the source file.

  2. Directories specified with the /I option, in the order that CL encounters them.

  3. Directories specified in the INCLUDE environment variable.

Now, the ["VC++ Directories" → "Include directories"] is documented as corresponding to the INCLUDE variable. I.e., these directories are searched last. According to the documentation.

And the ["C/C++" → "General" → "Additional Include Directories"] is documented as corresponding the /I option. I.e., these directories are searched first. According to the documentation.

Insofar as any best practice exists, it probably is

  • to leave open the possibility of overriding includes, and

  • to minimize the compiler invocation command line length (so as not to stress poor Windows – as I recall there was/is an 8 KB limit, or thereabouts).

I.e., use ["VC++ Directories" → "Include directories"] by default.


The complete set of environment variable correspondences:

  • ["VC++ Directories" → "Executable directories"] → PATH

  • ["VC++ Directories" → "Include directories"] → INCLUDE

  • ["VC++ Directories" → "Reference directories"] → LIBPATH (for #using)

  • ["VC++ Directories" → "Library directories"] → LIB


How did I find out this?

Simply by clicking in the GUI and pressing F1 for help. :-)

It's always a good idea to RTFM.