On Thu, 24 Aug 2000, Bernard Dautrevaux wrote:
> Probably the simplest (and more protable) cure would be to have an
> 'init_function_table' function that initialize the function array, like:
>
> void init_function_table() {
> static int initialized = 0;
> if (initialized) return;
> sg_func_table[0] = function_0;
> sg_func_table[1] = function_1;
> sg_func_table[2] = function_2;
> sg_func_table[3] = function_3;
> initialized = 1;
> }
>
> and either call it at the very beginning of your main program or, if it is a
> general purpose library used in numerous programs and performance is not too
> critical, call it at the very beginning of call_function (anyway any good C
> compiler like gcc should be able to integrate it in-line, especially if
> declared static, so the cost is only a test and branch).
That will work, but unfortunately, the tables that I have have
~250 function pointers in them, so this method is a little bit
awkward and relatively error prone...it is much easier to
just edit the static array.
But, if I get really stuck I may just do this.
Thanks!
-scott
--
Scott C. Gray <[EMAIL PROTECTED]> "my keybard is brken"
http://www.voicenet.com/~gray/sqsh.html