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