Maybe I missed some docs... But I found:

https://www.freepascal.org/docs-html/prog/progsu40.html#x47-460001.2.40

 1. It will look in the path specified in the include file name.
 2. It will look in the directory where the current source file is.
 3. it will look in all directories specified in the include file
    search path.


That leaves some questions though...

  {$I C:\test.inc}
- The path in the include file (point 1) is C:\ and that will be searched.
- 2 and 3 will NOT be searched (according to tests)

  {$I foo\test.inc}
  {$I .\foo\test.inc}
  {$I ..\foo\test.inc}
- the path in the include file itself is incomplete, and can't be searched as such
- 2 and 3 seem to be searched, OR RATHER it will search relative to them.

I am not sure, if I had a hidden setting, but it seems to me, there is ONE MORE path that is searched. - The path in which compilation started (that is the "current dir" / NOT the dir of the main unit/program)

Having

a/tmp/project.pp
    uses unit1 in 'a/tmp/foo/unit1.pas'

a/tmp/foo/unit1.pas
    {$I ./bar.inc}

a/bar.inc


and running
  cd a
  fpc tmp/project.pp

will find "bar.inc" in
- directory "a"  => current dir
- a/tmp/foo  => the dir of the unit (point 2)

I don't know the search order though.

I haven't done tests with extra include path...
_______________________________________________
fpc-devel maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to