delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/16/07:53:27

Date: Tue, 16 Feb 1999 14:49:11 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Laurynas Biveinis <lauras AT softhome DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: Defining startup functions with djgpp
In-Reply-To: <199902161153.GAA27025@delorie.com>
Message-ID: <Pine.SUN.3.91.990216144648.4795D-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On Tue, 16 Feb 1999, Laurynas Biveinis wrote:

> How can I specify some function to be called before function main?

Declare the functions with __attribute__((constructor)).  For example:

  static void __attribute__((constructor)) my_startup (void)
  {
    /* put here your code */
  }

Note that if you have several such functions, the order in which they are 
called is unpredictable (it's the order in which the linker sees them, 
and you have no real control on that).

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019