Comments: Authenticated sender is From: "George Foot" To: thomas DOT nyberg AT usa DOT net Date: Sun, 23 Aug 1998 23:14:29 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: What does __main do??? Reply-to: george DOT foot AT merton DOT oxford DOT ac DOT uk CC: djgpp AT delorie DOT com Message-Id: Precedence: bulk On 23 Aug 98 at 22:37, Thomas Nyberg wrote: > When you compile with asm-output ex. gcc -S test.c you there's a call to a > function called ___main (or__main), my question is: what does it do? and is > it possible to replace it (how)? You can replace it if you want -- write your own function called `__main' (in C, or `___main' in assembler). You probably don't want to do this though; replacing undocumented bits of the startup code is asking for trouble, unless you really understand what they're doing. DJGPP's startup code calls `__main' anyway during crt1; gcc seems to insert an extra call though as you noticed. DJGPP's `__main' calls constructors. It has a wrapper so that it only gets executed once per instance of the program. Its source code is in `src/libc/crt0/_main.c', within djlsr. -- george DOT foot AT merton DOT oxford DOT ac DOT uk