The FPC documentation says the following about include files:
The compiler will look for the file to include in the following locations:
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.
https://lazarus-ccr.sourceforge.io/fpcdoc/prog/progsu40.html#x47-460001.2.40However, whenever I try to follow point 1 above (specify a path in the include file name) I get an error. I tried both absolute and relative paths, for example:
{$include ..\inc_files\file.inc}
{$include C:\myfpc\inc_files\file.inc}
And so on. I'm sure the absolute and relative paths are correct and the file exists. I tried with \ and / path delimiters. I tried with and without quotes around the filenames. But the result is always an error: Fatal: Cannot open include file: "C:\myfpc\inc_files\file.inc"
The only way I found that works is to specify a folder for include files in the project options, and to use the file name without path in the $include directive. But I would prefer using relative paths once and for all, instead of having to specify Fi (include folders) in every single project I create.
In any case the official documentation clearly says that i should be able to specify a path with the filename, so why nothing seems to work?
Am I doing something wrong? Am I misreading the documentation? Can anyone kindly show me how to do it, or explain why it cannot be done?
Thank You!!