D - std.c.stdlib (atexit)
- =?iso-8859-1?Q?Miguel_Ferreira_Sim=F5es?= (20/20) Apr 07 2004 charset="iso-8859-1"
- Carlos Santander B. (21/39) Apr 07 2004 This works for me:
- Miguel Ferreira Simões (1/1) Apr 07 2004 thanks, it works!!!
charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable hi, again! i need some help... i am doing a singleton class (templated = with Destructors). the problem is that i don't know how to pass a D pointer to function to = the c function atexit (std.c.stdlib)!!! [compiler says: function atexit (void(C*)()) does not match argument = types (void(*)()) ] private import std.c.stdlib; extern (C) int atexit(void (*)()); interface IDestructor { public: void create(void (*dtor)()); } class DestructorAtExit : IDestructor { public: void create(void (*dtor)()) { atexit(dtor); } } thanks, Miguel Ferreira Sim=F5es
Apr 07 2004
In article <c51gsn$omq$1 digitaldaemon.com>, =?iso-8859-1?Q?Miguel_Ferreira_Sim=F5es?= says...hi, again! i need some help... i am doing a singleton class (templated = with Destructors). the problem is that i don't know how to pass a D pointer to function to = the c function atexit (std.c.stdlib)!!! [compiler says: function atexit (void(C*)()) does not match argument = types (void(*)()) ] private import std.c.stdlib; extern (C) int atexit(void (*)()); interface IDestructor { public: void create(void (*dtor)()); } class DestructorAtExit : IDestructor { public: void create(void (*dtor)()) { atexit(dtor); } } thanks, Miguel Ferreira Sim=F5esThis works for me: private import std.c.stdlib; alias void function () c_func; extern (C) int atexit(c_func); interface IDestructor { public: void create(c_func); } class DestructorAtExit : IDestructor { public: void create(c_func dtor) { atexit(dtor); } } import std.c.stdio; void foo() { printf("bye"); } void main() { (new DestructorAtExit).create( &foo ); } ------------------- Carlos Santander B.
Apr 07 2004