Index: src/instance.m ================================================================== --- src/instance.m +++ src/instance.m @@ -19,28 +19,24 @@ #import "OFObject.h" static SEL cxx_construct = NULL; static SEL cxx_destruct = NULL; -static void __attribute__((constructor)) -init(void) -{ - if (cxx_construct == NULL) - cxx_construct = sel_registerName(".cxx_construct"); - if (cxx_destruct == NULL) - cxx_destruct = sel_registerName(".cxx_destruct"); -} - id objc_constructInstance(Class cls, void *bytes) { id obj = (id)bytes; BOOL (*last)(id, SEL) = NULL; if (cls == Nil || bytes == NULL) return nil; + if (cxx_construct == NULL) + cxx_construct = sel_registerName(".cxx_construct"); + if (cxx_destruct == NULL) + cxx_destruct = sel_registerName(".cxx_destruct"); + object_setClass(obj, cls); /* FIXME: Constructors of superclasses should be called first */ for (; cls != Nil; cls = class_getSuperclass(cls)) { BOOL (*ctor)(id, SEL);