Forum
how to #include files with relative path to the current one? - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16)
+---- Thread: how to #include files with relative path to the current one? (/showthread.php?tid=258)



how to #include files with relative path to the current one? - programandala.net - 06-19-2010

#include <file> includes from the library; in order to include from the directory of the including file, the main program, i tried #include <./file> but it doesn't work. Even #include <~/path_to_the_project/file> doesn't work.

The only solution I've found is: #include </home/user/path_to_the_project/file>, that is, including the whole path from the file system root.

Is there any way to configure the including directories? It would be great to include files with relative path from the current directory if they exist, and from the library if they don't exist.


Re: how to #include files with relative path to the current one? - boriel - 06-19-2010

The standard way (e.g. C compilers) is use angles < ... > for compiler-library files. Use double quotes " ... " for your files. So try:
Code:
#include "filename.bas"
and this will include the file relative to your source path.


Re: how to #include files with relative path to the current one? - programandala.net - 06-19-2010

boriel Wrote:The standard way (e.g. C compilers) is use angles < ... > for compiler-library files. Use double quotes " ... " for your files.

How much distracted I was! Thank you. There is a mention about it in the Library page. An #INCLUDE page is coming Smile


Re: how to #include files with relative path to the current one? - britlion - 06-20-2010

programandala.net Wrote:
boriel Wrote:The standard way (e.g. C compilers) is use angles < ... > for compiler-library files. Use double quotes " ... " for your files.

How much distracted I was! Thank you. There is a mention about it in the Library page. An #INCLUDE page is coming Smile

I'm glad the library page is being appreciated :-)

Perhaps a page on # commands generally, linking to specifics? #include #Pragma, #line, #define #Ifdef.... etc.


Re: how to #include files with relative path to the current one? - boriel - 06-20-2010

britlion Wrote:
programandala.net Wrote:
boriel Wrote:The standard way (e.g. C compilers) is use angles < ... > for compiler-library files. Use double quotes " ... " for your files.

How much distracted I was! Thank you. There is a mention about it in the Library page. An #INCLUDE page is coming Smile

I'm glad the library page is being appreciated :-)

Perhaps a page on # commands generally, linking to specifics? #include #Pragma, #line, #define #Ifdef.... etc.
Yes, this goes into the *preprocessor* directives help. The zxbpp preprocessor is called automagically on each file before starting compilation/assembling.