Optimizing out unreferenced variables

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Fri May 10 00:42:57 AEST 1991


In article <1477 at ecicrl.ocunix.on.ca> clewis at 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



More information about the Comp.unix.programmer mailing list