Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!decwrl!sun!gorodish!guy From: guy@gorodish.Sun.COM (Guy Harris) Newsgroups: comp.lang.c Subject: Re: putting stuff in the text segment Message-ID: <54823@sun.uucp> Date: 28 May 88 22:31:50 GMT References: <3813@lynx.UUCP> <1457@laidbak.UUCP> Sender: news@sun.uucp Distribution: na Lines: 20 > I dunno of any language extensions, per se, to accomplish this. I think Apollo has the keyword "readonly" to do this. I suspect other vendors (DEC, in VMS C?) have added similar extensions. I know ANSI C has "const" which can be used to do this (and was, in fact, intended for this purpose, among others). > The most widely used method to do this is to cc -S, sed 's/data/text/', as. > Sun (OS3.2) has embellished cc with a -R flag that accomplishes the same > thing with a whole lot less trouble. 1) Credit where credit is due: Sun didn't add "-R", Berkeley did. 2) It may be less trouble than running the "sed" script. It is certainly *not* less trouble than having an explicit method in the language for indicating that *particular* objects should be stuck in read-only memory (or shared text, or whatever); "-R" is a very crude tool, and sticks *all* initialized data in the text segment. Sometimes this can be a *real* pain.