Compile time definitions

Brenton via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 5 14:56:55 PDT 2014


Is there a way to define a compile time constant/enum with dmd?  
For example, inserting the svn revision number into my code?  In 
C...

#include <stdio.h>
#ifndef SOMETHING
#define SOMETHING "bar"
#endif
int main() {
	printf("hello world: " SOMETHING " \n");
	return 0;
}


> gcc main.c && ./a.out
hello world: bar
> gcc -DSOMETHING=\"foo\" main.c && ./a.out
hello world: foo


How would you recommend I do something like this with D?


More information about the Digitalmars-d-learn mailing list