www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/08/01/07:01:05

Date: Thu, 1 Aug 1996 13:56:03 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: djgpp-workers AT delorie DOT com
Subject: Startup customization
Message-Id: <Pine.SUN.3.91.960801134448.5091F-100000@is>
Mime-Version: 1.0

There are cases when it is convenient to get some code run before `main'
is called.  A case in point is GNU Textutils and Fileutils, where some
programs need to switch their standard streams to O_BINARY, or convert all
command-line filenames to Unix forward-slash form.  In some cases there is
an alternative solution (put the code inside `main').  In other cases, the
DJGPP-specific code gets scattered across the entire source whereas it
could be put only in a single function if it would run before `main'.  In
any case, it is ugly and clutters the original sources, making it harder
to convince the maintainers to include the DJGPP-specific changes. 

Currently, the only other way is to provide custom crt1 functions, but 
they will need to duplicate most (if not all) of the code of existing 
functions.  I think it is a good idea to add a call to a user-definable 
function just before `main' is called.  The library will include an empty 
version of this function, but a user can define their customized version 
which will then be linked in instead of the default.

Comments?  Is one such function enough, or is there need for several
(say, before and after the command-line arguments are expanded)?

- Raw text -


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