delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/14/03:18:47

From: Christopher Bier <chbier AT yahoo DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: startup functions on gnu c/c++?
Date: Tue, 14 Apr 1998 02:07:00 -0500
Organization: LCC Internet
Lines: 32
Message-ID: <35330B14.F9D6578B@yahoo.com>
References: <199804120455 DOT XAA18360 AT waller DOT net> <35305DE9 DOT 4EC1 AT acadia DOT net>
NNTP-Posting-Host: conr-ddas1-a28.lcc.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Scott Warner wrote:
> 
> Conrad Wei-Li Song wrote:
> >
> > Quicky question:
> >
> > How to I define functions to be called on program startup before main is
> > called?
> > Thanks.
> 
> I don't think you can.  main() is always the first function called.  Why
> would you want to do such a thing?

Tickles my curiosity too! But, whatever your reasons, section 18.5 of 
the FAQ may help. While you might not be able to define new start-up 
functions, you can define your own versions of preexisting ones.

#include <stdio.h>

void __crt0_setup_arguments (void);

int
main (void)
 {
	printf ("Hello\n");
 }

void
__crt0_setup_arguments (void)
 {
	printf ("World!\n");
 }

- Raw text -


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