home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / amiga / programm / 18436 < prev    next >
Encoding:
Text File  |  1993-01-09  |  2.5 KB  |  62 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!well!comeau
  3. From: comeau@csanta.attmail.com (Greg Comeau)
  4. Subject: Re: Version Strings...
  5. Message-ID: <C0MEv9.Awr@well.sf.ca.us>
  6. Originator: comeau@well.sf.ca.us
  7. Keywords: optimization
  8. Sender: news@well.sf.ca.us
  9. Reply-To: comeau@csanta.attmail.com (Greg Comeau)
  10. Organization: Comeau Computing
  11. References: <1993Jan8.111612.25180@sunbim.be> <Per_Salmi.0lxs@augs.se> <81pgs*M00@ro-chp.UUCP>
  12. Date: Sun, 10 Jan 1993 04:23:32 GMT
  13. Lines: 47
  14.  
  15. In article <81pgs*M00@ro-chp.UUCP> chopps@ro-chp.UUCP (Chris Hopps) writes:
  16. >In article <Per_Salmi.0lxs@augs.se>, Per Salmi writes:
  17. >
  18. >> accs1@bagheera.mumath wrote:
  19. >
  20. >> : >UBYTE Version[] = "\0$VER: ProgName 1.0 (7.1.92)";
  21. >
  22. >> : I wonder why that stays in the executable. I would expect a good compiler would
  23. >> : through that line away unless it is really referenced.
  24. >
  25. >> You really got a point there! Why does it?
  26. >
  27. >The compiler has no idea its not referenced, becuase it can be referenced across
  28. >compilation units.
  29. >
  30. >You then might think that a good linker could optimize it out, but the logic behind
  31. >this would 1) probably never work right and 2) someone would find a reason the linker
  32. >should not be deleting non referenced data objects.  Plus how would we imbed strings
  33. >then? :^)
  34.  
  35. I've addressed the former in some posts yesterday so will direct you
  36. to them for that.  Re the latter, it can be made somewhat more likely
  37. to remain in simply by changing it to:
  38.  
  39.     UBYTE *VerPtr = "\0$VER: ProgName 1.0 (7.1.92)";
  40.  
  41. the reason being that it's simple enough to see what's not referenced,
  42. and hence it can throw away VerPtr quick enough, but as the initializer
  43. is somewhat more complicated (an unnamed array of char) it might not be
  44. smart enough to think of doing it (not that doing it is hard, but
  45. the compiler writer would have had to think of this... it would be harder
  46. than throwing VerPtr away though).  This could also be made somewhat
  47. incrementally more sly with something like:
  48.  
  49.     UBYTE *VerPtr[2] = { (UBYTE*)VerPtr, "\0$VER: ProgName 1.0 (7.1.92)" };
  50.  
  51. And assuming version is looking for the string rather than the symbol
  52. name, one could be better off putting the original definition within
  53. main() (again, this is no guarantee of it remaining still, just another
  54. alternative to illusion).
  55.  
  56. - Greg
  57. -- 
  58.          Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418
  59.                    Producers of Comeau C++ 3.0 With Templates
  60.           Here:attmail.com!csanta!comeau / BIX:comeau / CIS:72331,3421
  61.         Voice:718-945-0009 / Fax:718-441-2310 / Prodigy: tshp50a
  62.