putting stuff in the text segment

Guy Harris guy at gorodish.Sun.COM
Sun May 29 08:31:50 AEST 1988


> 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.



More information about the Comp.lang.c mailing list