Thank you all who have answered my question. Perhaps I should have given
you all a little more background on the problem, so that you wouldn't have
had to guess what it would be used for. This is what I'm trying to do: a
very small operating system built on threads and synchronous message
passing. I think it might provide an interesting environment for solving
some problems. As an example, consider this piece of code:

This is, in my opinion, almost like a closure in C. But why do all this
when there already are OSes that have IPC and light-weight processes? For
one thing, if you want to keep things small and in the same time fork
numerous threads, the notion of infinite stack can be a rather costly
issue. But this way those threads that would need an infinite stack could
be given one and the others could have a fixed-size stack of their
theoretical maximum.

The needed tool would then: 1 Get the theoretical maximal stack depth, 2
Be as machine independent as possible and 3 Process the code before
compilation. Or else you would have to patch the information into the
executable.
Sam