Date: Sun, 12 Apr 1998 12:16:29 +0300 (IDT) From: Eli Zaretskii To: Conrad Wei-Li Song cc: djgpp AT delorie DOT com Subject: Re: startup functions on gnu c/c++? In-Reply-To: <199804120455.XAA18360@waller.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Sat, 11 Apr 1998, Conrad Wei-Li Song wrote: > How to I define functions to be called on program startup before main is > called? Declare these functions with the ``constructor'' attribute, like this: static void __attribure__((constructor)) my_startup (void) { .... } Note that these functions are called in the order they are seen by the linker when it links the program. (This is only important if you have several such functions which depend on each other.)