RAII trouble

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Nov 20 15:20:01 PST 2015


On 11/20/2015 02:56 PM, Spacen Jasset wrote:

 > FT_Init_FreeType is a static which is set at some previous time to a
 > function entry point in the FreeType library.

 > text.d(143,15): Error: static variable FT_Init_FreeType cannot be read
 > at compile time

The compiler seems to think that FT_Init_FreeType is a variable. Is that 
really a function pointer? Can you show how it's defined.

My simple test works:

extern (C) int init_func(double){
     return 42;
}

static auto my_func = &init_func;

struct S {
     static S init() {
         return S(0);
     }

     this(int) {
         my_func(1.5);
     }
}

void main() {
     auto s = S.init();
}

Ali



More information about the Digitalmars-d-learn mailing list