Jump to content
Sign in to follow this  
ŁukaszDe

Should I use path in $Include file or not

Recommended Posts

I have unit in subfolder Forms.

In this unit on beginnig I have {$Include ../definitions}

File definitions.pas is in main folder.

Should I use '..\' in directive Include or not?

Is it help to faster find file definitions.pas by compiler?

It works with and without.

RadStudio accept '..\definitions' and '../definitions' too but Pascal Analyzer only '..\definitions'.

Edited by ŁukaszDe

Share this post


Link to post

I would love to use that even more often, but I'm very careful with this function too.

From my experiece this is not very reliable if you use more than one file of same name, which you want to use as default.

That depends on the search path which one is taken.

The documentation here says that it take the Search library path definitions, I hope that true that its also searches them in the right order.

If you change the search path order, then you might see strange errors in that case above.

 

Of course it should be ..\ on Windows, thats what I use there always.

 

 

Share this post


Link to post

File definitions.pas is only one in project in main folder but another units in subfolders including it.

Share this post


Link to post

Why do you use .pas as the file extension? I have never seen anything else but .inc for include files (OK, there is also .tpl but that's a very special case)

 

Regarding the use of the search path: The IDE uses it for include files and also in the given order. But beware: It also uses the library search path configured in Tools -> Options.

 

(And there is a very outdated jedi.inc file in some (or all?) Delphi installations. I don't exactly remember where because I deleted it when I stumbled upon it.)

Share this post


Link to post
4 hours ago, dummzeuch said:

Why do you use .pas as the file extension?

Because it is Lagacy Code... and has nothing to do with the question... 🙂

Share this post


Link to post
16 hours ago, dummzeuch said:

Why do you use .pas as the file extension?

http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/compdirsincludefile_xml.html

 

Quote

The $I parameter directive instructs the compiler to include the named file in the compilation. In effect, the file is inserted in the compiled text right after the {$I filename} directive. The default extension for filename is .pas. 

There is also written:

Quote

If filename does not specify a directory path...

So should be a path to included file?

Share this post


Link to post

If $I has a path (including relative), it is used based from the file containing $I directive.

If $I has no path, default Search paths are used.

  • Thanks 1

Share this post


Link to post
15 hours ago, ŁukaszDe said:

Because it is Lagacy Code... and has nothing to do with the question... 🙂

It might have.

When I tested .pas extensions, this might occur into strange temporary .$$$ files, when I try to debug and edit.

Not sure why that happened, but I moved back to .inc then.

 

Compiling and running should be fine, I am talking about the development process of such file, when opening it from the caller unit.

 

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×