Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!ncar!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.unix.programmer Subject: Re: Optimizing out unreferenced variables Message-ID: <8874:May914:42:5791@kramden.acf.nyu.edu> Date: 9 May 91 14:42:57 GMT References: <1475@ecicrl.ocunix.on.ca> <13206:May719:03:1491@kramden.acf.nyu.edu> <1477@ecicrl.ocunix.on.ca> Organization: IR Lines: 27 In article <1477@ecicrl.ocunix.on.ca> clewis@ferret.ocunix.on.ca (Chris Lewis) writes: > >It's a whole bunch more portable and useful to give the user some > >options to print out those strings. End of story. > What exactly do you mean by this? what(1)? No. what(1) is not supported by the language or the complete programming environment, so it is inherently unreliable. > A -V option? All that's important for this problem is that each library provide a routine that returns a version string. If you want this to work recursively, do something like void foovers(f) int (*f)(). foovers calls f with its version string as an argument. If f returns 1, foovers calls the barvers routines upon f for each library bar that it uses. Otherwise foovers just returns. Then you can accomplish different results by plugging in different f's. If you don't want to recurse, for instance, you just supply a function that prints its argument and returns 0. If you want to print strings like what(1), you supply a function that stores its argument in a hash table and returns 1 if the argument hasn't been seen before. Then you print all the strings in the table. If you want to trace package dependencies, you can do that too. ---Dan