home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / wizards / 5270 < prev    next >
Encoding:
Internet Message Format  |  1992-12-20  |  1.2 KB

  1. Path: sparky!uunet!auspex-gw!guy
  2. From: guy@Auspex.COM (Guy Harris)
  3. Newsgroups: comp.unix.wizards
  4. Subject: Re: What is text, data & bss anyway?
  5. Message-ID: <15988@auspex-gw.auspex.com>
  6. Date: 18 Dec 92 02:29:01 GMT
  7. References: <1992Dec15.085938.5975@ericsson.se> <15907@auspex-gw.auspex.com> <MOSS.92Dec16110746@CRAFTY.cs.cmu.edu>
  8. Sender: news@auspex-gw.auspex.com
  9. Organization: Auspex Systems, Santa Clara
  10. Lines: 23
  11. Nntp-Posting-Host: auspex.auspex.com
  12.  
  13. >Guy> What does GCC do with
  14. >
  15. >Guy>     const char foo[] = "abcd";
  16. >
  17. >Guy> I.e., does it put it in the text or data segments?  (Text segment, I
  18. >Guy> hope.)
  19. >
  20. >It puts it in the text segment by default. However, you can tell gcc to put
  21. >strings into the data segment (some programs actually expect to be able to
  22. >modify strings!) with the flag -fwritable-strings.
  23.  
  24. I hope, however, that even with the flag "-fwritable-strings", it'd put
  25. "foo" in the text segment in my example.
  26.  
  27. I.e., in my example, "abcd" isn't a string constant, it's a string
  28. initializer of a named array of "char".
  29.  
  30. What does GCC do with
  31.  
  32.     const int foo[] = { 1, 137, 666 };
  33.  
  34. Does it put it in the text or data segments?  (Text segment, I hope.) 
  35. The answer should be the same as the answer to my original question....
  36.