gcc 1.33 compiled and working fine on UNIX pc/3B1

Lenny Tropiano lenny at icus.islp.ny.us
Fri Feb 10 03:49:00 AEST 1989


In article <1092 at banzai.UUCP> roger at banzai.UUCP (Roger Florkowski) writes:
|>In article <594 at icus.islp.ny.us> lenny at icus.islp.ny.us (Me) write:
|>>The compiler compiled flawlessly with the stock UNIX pc compiler
....
|>A hint on using gcc:
|>
|>some programs 'like' it better if you use these flags:
|>
|>gcc -traditional -fwritable-strings
|>
...
|>-fwritable-strings	affects what gcc does with character strings.
|>			/lib/ccom allowed writable strings. (read man-page)
|>

It would be better to fix the kludgy code that is taking constants,
which the UNIX PC stock compiler puts in the "data" segment, and changing
the contents of them.

	char *mystring = "hello, world\n";

	Should go in the text segment (which the GNU gcc compiler does
	by default, unless specified with the -fwritable-strings option)
	which is sharable among processes on certain machines (I'm not
	sure how the UNIX pc handles it -- the old question of whether
	the "sticky-bit (t)" has any effect comes to mind again).

	It would not be good practice to modify "mystring" if it was
	initialized at compile time.  The UNIX PC stock /lib/ccom (C
	compiler) would allow this, because it places the string in
	the data segment, without -fwritable-strings, any attempt
	to modify the mystring variable under the GNU gcc compiler would
	cause a "Memory fault"

As the gcc documentation mentions, "constants should be constant!"
Of course if you feel that you don't want to bother hacking up bad
code to be correct, you can crutch on the -fwritable-strings compiler
flag.

-Lenny
-- 
Lenny Tropiano             ICUS Software Systems         [w] +1 (516) 582-5525
lenny at icus.islp.ny.us      Telex; 154232428 ICUS         [h] +1 (516) 968-8576
{talcott,decuac,boulder,hombre,pacbell,sbcs}!icus!lenny  attmail!icus!lenny
        ICUS Software Systems -- PO Box 1; Islip Terrace, NY  11752



More information about the Unix-pc.general mailing list