nested includes from subdirectory ... ?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

nested includes from subdirectory ... ?

Post by helpy »

Following directory structure:

Code: Select all

- source (directory)
  - main.pb (XIncludeFile "include\inc.pbi")
  + include (directory)
    - inc.pbi (XIncludeFile "sub_inc.pbi")
    - sub_inc.pbi
Compiler error ... "sub_inc.pbi" could not be found!

It would be nice if nested includes would be found by the compiler!

cu, helpy
Last edited by helpy on Fri Apr 07, 2006 9:59 am, edited 1 time in total.
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Post by helpy »

Maybe this is more a feature request, than a bug. than it should be moved to the appropriate forum.

thanks, helpy
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Post by horst »

see my posting: http://www.purebasic.fr/english/viewtop ... ncludepath

In an included file it is impossible to refer to its own directory.
Horst.
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Post by helpy »

horst wrote:see my posting: http://www.purebasic.fr/english/viewtop ... ncludepath

In an included file it is impossible to refer to its own directory.
That is BAD! For me it is a bug ...

I vote for changing this behaviour!

The bad thing is, that Import/ImportC also refer to the Include Path!

Scenario:
  • I have a Library and its *.pbi file (or several *.pbi files) in a seperate directory (.\main_source_directory\mylibrary_version_1_0)
  • In the pbi file there I use ImportC "mylibrary.lib"
  • At the moment I use the following in the main source file (in .\main_source_directory):

    Code: Select all

    IncludePath  "mylibrary_version_1_0"
    XIncludeFile "mylibrary.pbi"
    IncludePath  ""
    
  • If I use:

    Code: Select all

    XIncludeFile "mylibrary_version_1_0\mylibrary.pbi"
    ... the Library will not be found by the compiler
I really do not like this behaviour

cu, helpy
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

I've run into a similar issue.. trying to compartmentalise my includes into subfolders, and some of those PB includes include some other stuff in their own folder.. so in this case, it's a bit of a nightmare to get PB to compile from the top pb file without 'include not found' problems, and also still maintain 'portability' of these includes (for other projects).

I am not really sure of a solution, but I was thinking when compiling reaches these includes, if there is a import library reference (e.g. Import "mylib") it would be good if PB could first check the folder where the pb is (i.e. the folder of the pb file that has the reference to the lib), and try to resolve the lib there before going off anywhere else. The same thing could be done perhaps for any includes that particular pb file has also.

Alternatively, perhaps making includepath support more than one path, instead of just one for all files.
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Post by horst »

mskuma wrote:.. so in this case, it's a bit of a nightmare to get PB to compile from the top pb file without 'include not found' problems, and also still maintain 'portability' of these includes (for other projects).
I think, the solution is extremely simple:

(1) The default IncludePath is the path of the current file.
(2) An IncludePath statement is valid for the current file only.


Maybe a "Use path of main file" statement for sort of "Callback Includes" could be optional, but this should not be the only possible behaviour.
Horst.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

horst wrote:I think, the solution is extremely simple:

(1) The default IncludePath is the path of the current file.
(2) An IncludePath statement is valid for the current file only.
I think that makes sense. In any case, it certainly would be good to see any improvement to avoid these tangly situations.. I hope this is taken up as a valid issue. Thanks.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

I tried helpy's example with the 4.10 beta3 hoping it was resolved, but seems not. Seems like this more recent post is reporting a similar issue http://www.purebasic.fr/english/viewtopic.php?t=27722

Is there any chance this problem will be resolved in the near future? Thanks.
Post Reply