digitalmars.D.learn - How to get name of my application (project)
- Andrey (2/2) Aug 03 2019 Hello, how to get name of my application (project) that we write
- =?UTF-8?B?UsOpbXkgTW91w6t6YQ==?= (5/8) Aug 03 2019 If I understand the question correctly, you are looking for
- Jonathan M Davis (5/13) Aug 03 2019 Also, the first element in the array passed to main is the name of the
- Jacob Carlborg (12/14) Aug 05 2019 No, what's passed to "main" is the path to however the application was
- Bastiaan Veelo (5/8) Aug 03 2019 The name of an application is not a compile time constant: you
- drug (4/6) Aug 03 2019 You can get it using $DUB_PACKAGE from Environment variables
- James Blachly (12/14) Aug 03 2019 Dear Andrey:
Hello, how to get name of my application (project) that we write in dub.json? Is there any compile-time constant like __MODULE__?
Aug 03 2019
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
Aug 03 2019
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:Also, the first element in the array passed to main is the name of the executable. - Jonathan M DavisHello, 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
Aug 03 2019
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
Aug 05 2019
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.
Aug 03 2019
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.
Aug 03 2019
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.
Aug 03 2019