aw0g+@andrew.cmu.edu (Aaron Wohl) (05/27/88)
In C Double quote literals count in the 32K limit. As an aid to port some large unix programs to the macintosh I made a string preprocessor that is run as part of compiling each program. It eliminates the data space used by string literals. The strings live in a resource which is loaded at runtime. Since it is a lexical preprocessor it can't handle strings in static structure initilization or private static strings in functions. With just a few source changes I was able to port a system with of 60K of strings. 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 <stdio.h> main() {printf("hello world\n"); printf("foo\n"); } becomes: char *qv_barf; ... expansion of #include <stdio.h> ... 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)
singer@endor.harvard.edu (Jon Hueras) (05/28/88)
In article <gWbIlTy00WA1I6fUli@andrew.cmu.edu> aw0g+@andrew.cmu.edu (Aaron Wohl) writes: >In C Double quote literals count in the 32K limit. FYI, in LightspeedC string literals do not contribute to the 32K limit unless they are used as array initializers (natch). Rich Siegel Quality Assurance Technician THINK Technologies Division, Symantec Corp. Internet: singer@endor.harvard.edu UUCP: ..harvard!endor!singer Phone: (617) 275-4800 x305