How to write generic hook for functions in C?
<p>I want to write a hook function that is called whenever a function is called in my program to gather some statistics about the arguments of the function. For example:</p>

<pre><code>void hook(function f, ...){
    //some statistics here
    f(...);
}
int main(){
    foo(1, 2);
}
</code></pre>

<p>So instead of calling <code>foo</code> directly, it will call hook instead with <code>foo</code> as its first argument and <code>1, 2</code> as extra arguments.</p>

<p>Is there anything similar to this in C? Can I achieve this goal in C in any other way?</p>