I am writing a program in C/C++(but c++ class should not be involved) which is divided into 2 parts. The first is basic need for threads and processes. The second is for users to customizing their own functions. the module is like, what puzzles me is the user-customizing functions.
My Need is as following:
Users can create a new *.c file in a given folder, they can write their own functions.
after they made their own functions, and compilation, i provide them with an interface maybe via socket or http, or argv command. they can evoke the functions they defined before. they only give me a string like "own_funciton", and then I call the function they defined.
The question is : how to do this? How can i connect the strings and the functions???
I think maybe MACRO may be a solution, I ask users to define their function like this: This is just an example
BEGIN_FUNCTION (own_funcion) { //function body } END_FUNCTION
HEED:when users add their new functions, whole system need to be recompiled.
you can do something in the MACRO BEGIN_FUNCTION to store the function string and the function pointer.. But I dont know how to write the MACRO specifically.. Do you have any advice