Consider:

// app.d

import std.stdio;
import tracemodule;

mixin traceModule;

void main()
{
  writeln("main");
}

// tracemodule.d

module tracemodule;

import std.stdio;

mixin template traceModule(string moduleName = __MODULE__)
{
  import std.stdio;

  static this()
  {
    writeln("init " ~ moduleName);
  }

  static ~this()
  {
    writeln("deinit " ~ moduleName);
  }
}

When I compile like this:

$ rm -f *.o *.di
$ dmd -c tracemodule.d
$ dmd -c app.d
$ dmd app.o tracemodule.o -of=app

...and run 'app' I get the expected output:

$ ./app
init app
main
deinit app

Now if I throw -H in, things get weird:

$ rm -f *.o *.di
$ dmd -c -H tracemodule.d
$ dmd -c app.d
$ dmd app.o tracemodule.o -of=app
$ ./app
init app
main

Indeed when I look at the content of the interface file, I see:

// D import file generated from 'tracemodule.d'
module tracemodule;
import std.stdio;
template traceModule(string moduleName = __MODULE__)
{
        import std.stdio;
        static this()
        {
                writeln("init " ~ moduleName);
        }
}

'static this()' is there, but no 'static ~this()'.

What's happening here?



Reply via email to