[Lazarus] __FILE__ macro, or equivalent

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] __FILE__ macro, or equivalent

Donald Ziesig
Hi All!


I would like to get the path to an fpc package at compile time. I have a
package which needs to load some .so files and I would like to store
them in a location that will be consistent when I move the package from
system to system.  By getting the package path, I could store them in
the package directory.


Is that possible?


I tried to use the __FILE__ macro like in C/C++ but the compiler doesn't
seem to understand it.


Thanks,


Don Ziesig

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] __FILE__ macro, or equivalent

Mark Morgan Lloyd
Donald Ziesig wrote:

> Hi All!
>
> I would like to get the path to an fpc package at compile time. I have a
> package which needs to load some .so files and I would like to store
> them in a location that will be consistent when I move the package from
> system to system.  By getting the package path, I could store them in
> the package directory.
>
> Is that possible?
>
> I tried to use the __FILE__ macro like in C/C++ but the compiler doesn't
> seem to understand it.

Try something like

B5k5_Project := {$I %FILE% } ;        (* Possibly used for .ini files
etc.    *)

http://www.freepascal.org/docs-html/current/prog/progsu41.html#x48-470001.2.41

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] __FILE__ macro, or equivalent

Donald Ziesig
On 07/29/2016 01:47 PM, Mark Morgan Lloyd wrote:

> Donald Ziesig wrote:
>> Hi All!
>>
>> I would like to get the path to an fpc package at compile time. I
>> have a package which needs to load some .so files and I would like to
>> store them in a location that will be consistent when I move the
>> package from system to system.  By getting the package path, I could
>> store them in the package directory.
>>
>> Is that possible?
>>
>> I tried to use the __FILE__ macro like in C/C++ but the compiler
>> doesn't seem to understand it.
>
> Try something like
>
> B5k5_Project := {$I %FILE% } ;        (* Possibly used for .ini files
> etc.    *)
>
> http://www.freepascal.org/docs-html/current/prog/progsu41.html#x48-470001.2.41 
>
>
Thanks Mark,


Unfortunately, that directive only returns the file name itself, without
the path.  The documentation does not show any %xxx% symbol that returns
the full file path, which is what I need.  I will have to set an
environment variable to do what I want, but that will leave me with just
one more thing to forget when I port the package :-(.


Don

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] __FILE__ macro, or equivalent

Alex
Hello,

IMO it is worth to ask FPC dev's, to make variable %FILE_PATH% along with the %FILE% (which exists). You can ask at Mantis about it.

Alex


Regards,
Alex
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus