Results 1 to 4 of 4

Thread: array of pointers to functions

  1. #1
    Join Date
    Aug 2006
    Posts
    83

    Default array of pointers to functions

    Hello,

    I must write a programme in which I have to implement a "handler" which will call the apropriate function from a predefined list of function in C/C++, based on the integer which I have given from the command line.

    example: ./program 5 -> will make a system call (a function which is in 5th place in the sys_call_table[])

    I was hoping that someone could help me to start, because I don't know how to begin.

    tnx

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: array of pointers to functions

    Do these functions have the same number and types of parameters?

  3. #3
    Join Date
    Aug 2006
    Posts
    83

    Default Re: array of pointers to functions

    hmm... This is a set of system function or system calls:
    one function is printf, the other is something else so I think that they have different set of parameters...
    I have to do the same thing that the operating system uses to make a system call. It calls a function in the array accordingly to a specified address in the array.
    example:
    printf has some specified address in the array and it automatically calls that addres when needed. My programme has to call that function if I specify the same address in the array but I have to do that explicitly ( I have to perform the call of that function accordingly to the specified position in the array).

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: array of pointers to functions

    Remember that you won't be allowed to do some things which the kernel is allowed to do. In your situation I would use a switch() block to handle each call separately. You'll probably have to map all the arguments to some generic type like void* before entering the switch() and then remap them to proper types when calling the methods. If you were using Qt, I'd tell you to use QMetaObject::invokeMethod(), but I guess you don't use Qt

Similar Threads

  1. Qt/Embedded Installation error during make
    By mahe2310 in forum Installation and Deployment
    Replies: 5
    Last Post: 7th September 2006, 04:05
  2. How to create QPixmap from unsigned character array?
    By rashidbutt in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 18:25
  3. array + template ?
    By mhoover in forum General Programming
    Replies: 3
    Last Post: 10th February 2006, 19:23
  4. QSettings again ... how to remove array elements
    By Mike in forum Qt Programming
    Replies: 4
    Last Post: 11th January 2006, 08:58
  5. loading array values directly
    By jamadagni in forum General Programming
    Replies: 5
    Last Post: 8th January 2006, 17:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.