How does Understand find C++ include files?

Exactly like a C/C++ compiler with one addition.

Include paths are specified either in the Project->Configure dialog, Includes tab, or on the command line of the ‘und’ parser

When looking for an include file Understand for C++ uses this search precedence:

1. absolute name
2. relative to parent dir
3. in project include list
4. in system specific (compiler) dir (same as compiler to this point)
5. in project files (we added to help typical users)
Steps 1 and 4 are identical to a C/C++ compiler. Step 5 is an additional search we provide for cases where code (or compile macros) are incomplete.

More on step 5, which internally we call “lazy include”… this is there as an aid, but it can lead to incorrect parsing. For instance if your tree has these files:

  • include/foo.h
  • util/foo.h
  • main.cpp

and main.cpp includes “foo.h” but there is no path then it will pick one of the two foo.h’s in the project.
Perhaps the wrong one… the correct thing to do is to specify “include” ahead of “util” on your include path – if that is the precedence you prefer.