sasagawa888 / eisl

ISLisp interpreter/compiler
Other
272 stars 22 forks source link

Compile error #220

Closed sasagawa888 closed 1 year ago

sasagawa888 commented 1 year ago

It seems to be a side effect of changing the library's folder. Please help me.

(compile-file "example/tarai.lsp") type inference initialize pass1 pass2 compiling TARAI compiling FIB compiling FIB* compiling ACK compiling GFIB compiling TAK compiling LISTN compiling TAKL compiling CTAK compiling CTAK-AUX finalize invoke CC example/tarai0.c:13:10: fatal error: example/tarai1.c: No such file or directory 13 | #include "example/tarai1.c" | ^~~~~~ compilation terminated.

poldy commented 1 year ago

I took a quick look at this. The root cause is the "-I" options in the "cc" command line, in functions compile-file1 and compile-file1* in library/compiler.lsp.

At the moment, unless it has already been set, $EASY_ISLISP is set to share/eisl in the PREFIX. So the -I option will be -I/usr/local/share/eisl (for instance). This will fail to find files in $HOME/eisl/example. One workaround is to set EASY_ISLISP in your environment to $HOME/eisl before starting "eisl -c" (it will override the default), I checked and this works.

It may be a good idea to add "-I." (i.e. the current directory) to the "-I$EASY_ISLISP " options in compiler.lsp.

sasagawa888 commented 1 year ago

Thank you for your quick comment.

Before reading the comments, I thought about it myself and tried to improve it. Changed compiler's (finalize fname ".c") to (finalize (remove-dir fname) ".c"). remove-dir removes the directory part.

It looks like it worked. Is this the correct solution?

poldy commented 1 year ago

Yes, that's even better than what I was thinking of. From the "Notes" section of https://en.cppreference.com/w/cpp/preprocessor/include ,

"The intent of syntax (2) is to search for the files that are not controlled by the implementation. Typical implementations first search the directory where the current file resides then falls back to (1)."

So it should look for files in #include "" relative to the including file, which is what is required.

sasagawa888 commented 1 year ago

Thank you very much.