Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    how to implement a function table

    I have a project, which need to implement a function table for multiple thread call, each thread will start with a different function, and the function table should be a good solution, but I can not find the good reference or programming guide for it.
    Please help me out, either a sample (working sample) or an URL.

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Nottingham, England
    I normally use something like this:

    // start with a typedef for the function - all must be the same return/param types
    typedef int fn_declaration_type(int, int);
    // pre-declare the functions
    int entry_fn_one(int, int);
    int entry_fn_two(int, int);
    int entry_fn_three(int, int);
    // declare a table
    fn_declaration_type fn_table[FN_TABLE_SIZE] = 
    // implement the functions
    int entry_fn_one(int a, int b)
        return 0;
    int entry_fn_two(int a, int b)
        return 0;
    int entry_fn_three(int a, int b)
        return 0;
    It's a bit more difficult if you want the functions wrapped in a class, but it is still possible.
    Linux user #126863 - see

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts