Passing revision tag to the compiler

Leandro Motta Barros lmb at stackedboxes.org
Sat Mar 30 18:42:15 PDT 2013


Hello,

I'd like to include the version control revision tag in a program. In
the C/C++ world I'd make my build system call the compiler like this:

   g++ -D<MY_REVISION_HERE> .....

so that the revision is available as a preprocessor symbol.

Is there an easy way to achieve the same in D? I can think of
convoluted solutions, like making the build system generate a .d file
containing a constant with the revision tag, but I'd naturally prefer
a simpler solution.

I am using DMD, but a solution that works for other D compilers gets
extra credit :-)

Thanks!

LMB


More information about the Digitalmars-d-learn mailing list