Path: utzoo!mnetor!uunet!husc6!bbn!rochester!pt.cs.cmu.edu!andrew.cmu.edu!aw0g+ From: aw0g+@andrew.cmu.edu (Aaron Wohl) Newsgroups: comp.sys.mac.programmer Subject: Re: Need better linker for MPW C Message-ID: Date: 29 Apr 88 11:09:46 GMT References: <4603@batcomputer.tn.cornell.edu> Organization: Carnegie Mellon Lines: 50 In-Reply-To: <4603@batcomputer.tn.cornell.edu> I ran into the same problem. In my case most of the static space was in double quote literals. I made up a preprocessor MPW tool that removes the double quote literals and replaces them with a macro. The strings are loaded at runtime from a resource file. This cuts data space usage from one byte per string character to 4 bytes per c source file. If this doesn't free up enough space change a few large arrays to be pointers to malloced(NewPtr) memory. The preprocessor is available from [ghostwheel,128.2.35.1] via anonymous ftp as the file gstring.tar. (gstring, strip down to the most bare that is legal). Don't forget to transfer it in binary mode. See the sample .r file and Makefile for how to use it. The following are handled: A sample expansion for file barf.c: #include main() {printf("hello world\n"); printf("foo\n"); } becomes: char *qv_barf; ... expansion of #include ... main() {printf((qv_barf+0L)); printf((qv_barf+14L); } So executable code works well. Initilized statics are more trouble. Statics declared inside functions are not handled. Private staticaly allocated strings (with 'static') become global. [static] char *string1="s1"; this becomes char *string1=0L; with code to initilize the string at startup [static] char *str_array[]={ "ar1", "ar2", }; This is initilized at startup in a similer fashion. [static] char mumble[]="mumble"; This is left as is so sizeof(mumble) works. Well anyway, gstring is rather ad hoc and doesn't handle everything. It did save the day in porting a large unix land program to the mac. Aaron Wohl (aw0g+@andrew.cmu.edu)