Page 1 of 1

[25 Apr 2009] include command

Posted: Sat Jun 13, 2020 5:32 pm
by Clyde
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 25 Apr 2009 23:36:17 +0200

Hi Andreas,
Seems like some problem in the program structure. You have to remember that an @INCLUDE command is really the same as if you would paste the file you specify in @INCLUDE to the source file. Hollywood will do nothing more on an @INCLUDE, then to paste the whole specified file into the current file.
The current implementation of @INCLUDE leads into a problem: Let's say, my main source file (main.hws) includes lib1.hws, which I put into a separate folder called "include". So in main.hws I write:

@INCLUDE "include/lib1.hws"

Now let's assume, under "include" I have a second file called "lib2.hws". But this file is not included by "main.hws" but by "lib1.hws". Now if I compile the code, compilation aborts, as the compiler now needs "lib2.hws" in the same directory as "main.hws". :-( But would be better, if the relative path to file that included the other file would be used.

Thanks a lot in advance!

Greetings, Micha

[26 Apr 2009] Re: include command

Posted: Sat Jun 13, 2020 5:32 pm
by bistullapagredo
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 26 Apr 2009 01:18:44 +0100

Hi Michael,
Now let's assume, under "include" I have a second file called "lib2.hws". But this file is not included by "main.hws" but by "lib1.hws". Now if I compile the code, compilation aborts, as the compiler now needs "lib2.hws" in the same directory as "main.hws". :-( But would be better, if the relative path to file that included the other file would be used.
I don't know if I got that right: You have a file main.hws that contains this line

@INCLUDE "include/lib1.hws"

and you have the file ./include/lib1.hws that contains that line

@INCLUDE "lib2.hws"

right?

Well, if I interpreted your explanation right, I'd say the compiler is correct. I didn't check that with hollywood, but e.g. any C compiler will do it the same way: include paths are always relative to the path the compiler was called from, not relative to where a specific file was included from.

So no matter where your project files are stored, you will have to tell the compiler any relative path inside the project directory structure. Change your INCLUDE statement in lib1.hws to

@INCLUDE "include/lib2.hws"

and it should work.

If I didn't interpret your explanation right, well, then sorry for the rant. ;-)

good night. :-)

[26 Apr 2009] Re: include command

Posted: Sat Jun 13, 2020 5:32 pm
by airsoftsoftwair
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 26 Apr 2009 12:08:39 +0200
I don't know if I got that right: You have a file main.hws that contains this line @INCLUDE "include/lib1.hws"

and you have the file ./include/lib1.hws that contains that line @INCLUDE "lib2.hws"

right?

Well, if I interpreted your explanation right, I'd say the compiler is correct. I didn't check that with hollywood, but e.g. any C compiler will do it the same way: include paths are always relative to the path the compiler was called from, not relative to where a specific file was included from.
No, Michael is right :-) Include paths should always be relative to the file that is including. C compilers do it the same way which is also the only logical way imho. So this really seems to be a compiler bug in Hollywood. I'll change this behaviour in the next update.