On Friday, 27 December 2013 at 11:56:08 UTC, Ali Çehreli wrote:
However, __FILE__ happens to be the current source file that is
being compiled but I think the OP wants the current compilation
directory. Being a C library file, getcwd() does not work at
compile time:
import std.stdio;
void main()
{
import std.path: dirName;
enum compiledFile = __FILE__;
writeln(compiledFile);
static const compileTime = __DATE__ ~ " " ~ __TIME__;
writeln(compileTime);
/*
import std.file: getcwd;
static const compilationDir = getcwd();
writeln(compilationDir);
Error: getcwd cannot be interpreted at compile time,
because it has no available source code
*/
}
Ali
Yes, just like what Ali said above,
__FILE__, __DATE__ and __TIME__ do work for their respective
usages,
but I'm also looking for a way to get the current compilation
directory during compile time, and getcwd() doesn't seem to be
working.
Isn't there something like __DIR__ or __PATH__ that I can use to
get that information?
-Ravn-