compile-time variables?

Fraser fraserofthenight at gmail.com
Thu May 24 14:54:13 PDT 2007


BCS Wrote:
> ...
> 
> const int Baz = 0;
> pragma(msg, "#define Baz 0\n")
> template Foo(A...)
> {
>      pragma{msg,"template Foo("~convert_Tuple_To_Args_List_And_Specilization!(A)~"){const 
> int Foo = Baz;}\n#define Baz (Baz+1)\n")
> }
> 
> Use this Foo everywhere you need it (with enough stuff in A to make each 
> use unique).
> Compile everything, pipe through cpp, recompile with the resulting code in 
> place of the original code.
> 
> I will now retreat to my lair to repent for that blasphemy. <g>
> 
> 

Heh; works like a charm! Thanks for that hackery!



More information about the Digitalmars-d mailing list