<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
Maybe I missed some docs... But I found:<br>
<br>
<a class="moz-txt-link-freetext" href="https://www.freepascal.org/docs-html/prog/progsu40.html#x47-460001.2.40">https://www.freepascal.org/docs-html/prog/progsu40.html#x47-460001.2.40</a><br>
<blockquote type="cite">
<ol class="enumerate1">
<li class="enumerate" id="x47-46002x1">It will look in the path
specified in the include file name. </li>
<li class="enumerate" id="x47-46004x2">It will look in the
directory where the current source file is. </li>
<li class="enumerate" id="x47-46006x3">it will look in all
directories specified in the include file search path.</li>
</ol>
</blockquote>
<br>
That leaves some questions though...<br>
<br>
{$I C:\test.inc}<br>
- The path in the include file (point 1) is C:\ and that will be
searched.<br>
- 2 and 3 will NOT be searched (according to tests)<br>
<br>
{$I foo\test.inc}<br>
{$I .\foo\test.inc}<br>
{$I ..\foo\test.inc}<br>
- the path in the include file itself is incomplete, and can't be
searched as such<br>
- 2 and 3 seem to be searched, OR RATHER it will search relative to
them.<br>
<br>
I am not sure, if I had a hidden setting, but it seems to me, there
is ONE MORE path that is searched. <br>
- The path in which compilation started (that is the "current dir" /
NOT the dir of the main unit/program)<br>
<br>
Having <br>
<br>
a/tmp/project.pp<br>
uses unit1 in 'a/tmp/foo/unit1.pas'<br>
<br>
a/tmp/foo/unit1.pas<br>
{$I ./bar.inc}<br>
<br>
a/bar.inc<br>
<br>
<br>
and running<br>
cd a<br>
fpc tmp/project.pp<br>
<br>
will find "bar.inc" in <br>
- directory "a" => current dir<br>
- a/tmp/foo => the dir of the unit (point 2)<br>
<br>
I don't know the search order though.<br>
<br>
I haven't done tests with extra include path...<br>
<br>
</body>
</html>