Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-07

__FILE__ macro, or equivalent

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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

Reply by email

Mark Morgan Lloyd
to Donald Ziesig
Donald Ziesig wrote 12 lines
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]

Reply by email

Donald Ziesig
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 22 lines
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

Reply by email