How to compile and link simple application?
Julian
julian.fondren at gmail.com
Mon Apr 8 18:54:10 UTC 2019
On Monday, 8 April 2019 at 18:47:42 UTC, 4544fa8d wrote:
> On Monday, 8 April 2019 at 18:41:00 UTC, Adam D. Ruppe wrote:
>> Did you put your code inside a main() function?
>
> I want to make constant with path to directory containing
> executable. This line is above main():
> -----------------------------
> const ROOT_DIR = dirName(thisExePath());
> -----------------------------
>
> This is not allowed? :O
That would give you dmd's path, if it worked.
This is allowed:
#! /usr/bin/env rdmd
import std.stdio, std.path, std.file;
@property
string root_dir() {
static string cache;
static bool isInit = false;
if (!isInit) {
isInit = true;
cache = dirName(thisExePath());
}
return cache;
}
void main() {
writeln(root_dir);
}
More information about the Digitalmars-d-learn
mailing list