Re: How to get name of my application (project)
On 2019-08-03 17:58, Jonathan M Davis wrote: Also, the first element in the array passed to main is the name of the executable. No, what's passed to "main" is the path to however the application was invoked, not the executable. If you invoke it as "./foo" it will pass "./foo" to the "main" function. If you invoke it as "/usr/local/bin/foo" it will pass "/usr/local/bin/foo" to the "main" function. That's at least how it works on macOS. "thisExePath" will give you the full path to the executable regardless how if it was invoked. It will resolve symlinks as well. So it depends on what's needed. "name of application" is a bit diffuse statement. -- /Jacob Carlborg
Re: How to get name of my application (project)
On Saturday, August 3, 2019 5:47:33 AM MDT Rémy Mouëza via Digitalmars-d- learn wrote: > On Saturday, 3 August 2019 at 09:26:03 UTC, Andrey wrote: > > Hello, how to get name of my application (project) that we > > write in dub.json? Is there any compile-time constant like > > __MODULE__? > > If I understand the question correctly, you are looking for > std.file.thisExePath: > - http://dpldocs.info/experimental-docs/std.file.thisExePath.html > - https://dlang.org/phobos/std_file.html#thisExePath Also, the first element in the array passed to main is the name of the executable. - Jonathan M Davis
Re: How to get name of my application (project)
On 8/3/19 5:26 AM, Andrey wrote: Hello, how to get name of my application (project) that we write in dub.json? Is there any compile-time constant like __MODULE__? Dear Andrey: Perhaps this is similar to what you are looking for: https://dlang.org/spec/grammar.html#SpecialKeyword SpecialKeyword: __FILE__ __FILE_FULL_PATH__ __MODULE__ __LINE__ __FUNCTION__ __PRETTY_FUNCTION__ These are available at compile time. Kind regards.
Re: How to get name of my application (project)
03.08.2019 12:26, Andrey пишет: Hello, how to get name of my application (project) that we write in dub.json? Is there any compile-time constant like __MODULE__? You can get it using $DUB_PACKAGE from Environment variables (https://dub.pm/package-format-sdl), for example using preBuildCommands you can generate a module and define the constant you need there.
Re: How to get name of my application (project)
On Saturday, 3 August 2019 at 09:26:03 UTC, Andrey wrote: Hello, how to get name of my application (project) that we write in dub.json? Is there any compile-time constant like __MODULE__? The name of an application is not a compile time constant: you can rename the executable at any time. Like Rémy said, thisExePath.baseName will get you the name at run time. Bastiaan.
Re: How to get name of my application (project)
On Saturday, 3 August 2019 at 09:26:03 UTC, Andrey wrote: Hello, how to get name of my application (project) that we write in dub.json? Is there any compile-time constant like __MODULE__? If I understand the question correctly, you are looking for std.file.thisExePath: - http://dpldocs.info/experimental-docs/std.file.thisExePath.html - https://dlang.org/phobos/std_file.html#thisExePath
How to get name of my application (project)
Hello, how to get name of my application (project) that we write in dub.json? Is there any compile-time constant like __MODULE__?