static this not run?
    user1234 
    user1234 at 12.lo
       
    Sat Sep 30 08:49:14 UTC 2017
    
    
  
On Saturday, 30 September 2017 at 06:15:41 UTC, Nicholas Wilson 
wrote:
> No "initialising onError", the static this is not even being 
> run!
> I'm using LDC master.
>
> See also https://github.com/libmir/dcompute/issues/32
LDC 1.4, DMD 2.076, DMD ~master and finally GDC all give the 
expected result here
"initialising onErrorinitialising onError: funcptr = 0x<some 
address>"
each time using:
---
enum Status {success,}
class StatusException : Exception
{
     this(Status s) {this.s = s;super("");}
     Status s;
}
void delegate(Status) onError;
static this()
{
     import core.stdc.stdio;
     printf("initialising onError");
     onError = (Status s) { throw new StatusException(s);};
     printf("initialising onError: funcptr = 0x%x", 
onError.funcptr);
}
void main()
{
     import std.stdio;
     writeln(onError.funcptr);
}
---
    
    
More information about the Digitalmars-d-learn
mailing list