From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Size of executable too large. Date: Thu, 29 May 1997 20:20:27 +0000 Organization: Two pounds of chaos and a pinch of salt Message-ID: <338DE50B.5387@cs.com> References: <338CF04B DOT EFB AT tiac DOT net> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp109.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 63 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Claude Sassine wrote: > > "If your program doesn't need parts of the startup code, it can be made > smaller by defining certain functions with empty bodies. These > functions are `__crt0_glob_function', `__crt0_load_environment_file', > and `__crt0_setup_arguments.'..." > > I am not sure what is meant by empty bodies, supposedly: The proper syntax for this is as follows: #include char **__crt0_glob_function(char *_argument) { return NULL; } void __crt0_load_environment_file(char *_app_name) { return; } void __crt0_setup_arguments(void) { return; } You can write these on one line each to save space, and omit the return; statements in the last two. The important thing to remember is that these are library functions, and that __crt0_glob_function() MUST return a NULL or your program will crash. > or undefining it in some way. Even if this is true, judging from the > size hello.c file in comparison to the size of its executable, the > compiler still generates an enormous output. I wonder what steps to > take. You obviously didn't read the entire section of the FAQ, since you completely missed the explanation of why a "hello world" program is so big. DJGPP is a 32-bit protected mode compiler. The startup code (which comprises most of such a small program) handles the following: - Detecting the presence of DPMI in the environment, and loading cwsdpmi.exe if it is not detected. - Detecting a floating point coprocessor, and loading FP emulation if a coprocessor is not detected. - Initializing DPMI, setting up interrupt handlers, and running the actual program. - Reading the command line arguments and expanding them. - Reading the DJGPP environment file and adding the relevant entries to the program's environment. - Detecting and initializing Win95 long filename support. - Various other miscellaneous tasks. All of this effort is completely wasted if all you want to do is print "Hello, world." to the screen and exit. Please try comparing the size of DJGPP programs in a _realistic_ situation. -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com | | "Starting flamewars since 1993" | http://www.cs.com/fighteer | | *** NOTICE *** This .signature is generated randomly. | | If you don't like it, sue my computer. | ---------------------------------------------------------------------