Xref: news2.mv.net comp.os.msdos.djgpp:2906 Newsgroups: comp.os.msdos.djgpp Subject: How safe is this? Message-ID: <4laoi6$cgk@groa.uct.ac.za> From: fnunez AT cs DOT uct DOT ac DOT za (Fabian Nunez) Date: 20 Apr 1996 13:24:22 GMT Organization: University of Cape Town NNTP-Posting-Host: phoebe.cs.uct.ac.za Lines: 30 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hi all! Last night I was fooling around and the idea struck me of making a function run automatically before main() starts up. I thought about it for a while and came up with this little gem: /* autostart.cc */ extern "C" void start(void); class __autorun__ { public: __autorun__(void) { start(); }; } __autorun__; Compiling this sucker to a .o file and linking it with plain C programs (for C++ programs change 'extern "C"' to just 'extern') will cause a function called 'start' to run before main(). My question is - how save and/or portable is this? Thanks Fabian -- Fabian Nunez, Bachelor of Computer Science, University of Cape Town email:fnunez AT cs DOT uct DOT ac DOT za web:http//www.cs.uct.ac.za/~fnunez ---------------------------------------------------------------- "k3wl aRe th3 lAmErz, 4 thEy sh4ll RulE!" - from the ElitE Bible