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?

You can use this ugly hack:

Create a shell script with the following content.

#!/bin/bash
echo `pwd` > dir.txt
dmd main.d -J.

And the D source code:

module main;

enum compilePath = import("dir.txt");
pragma(msg, compilePath);

Run the shell script to compile the D code.

--
/Jacob Carlborg

Reply via email to