Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>C is a statically compiled language, as such it doesn't make creating functions during runtime easy, or even generally possible. You could write out the C code you need to a .c file, execute a compiler on the system, and then dynamically load the object library. In the course of writing out the initial .c file you could name the function what ever you wanted. In short though, using macros won't work to do what you want to do. And using the method I've just mentioned is a massive hack. Possible, but ill advised.</p> <p>If you just want to rename a function, or choose from a limited set of functions you know in advance and can compile into the program, then you can use a function pointer. But this strikes me as the reverse of what you are trying to do, because the function pointer provides you with a static name (symbol) which can be used to call variable functions.</p> <p>If you really need to rename a function pointer, you could keep an array of function pointers, and index them using a string mapping. Then call your functions by looking up their pointers via their strings (names). the string is of course mutable, so you can change the 'name' of your function. But this is a very roundabout route and I honestly can't see a good reason to do this.</p> <p>Finally, the most useful and correct solution would be to implement a virtual machine with it's own symbol table. There are implementations out there already; <a href="http://docs.python.org/extending/embedding.html" rel="nofollow">Python</a> and <a href="http://www.jedsoft.org/slang/" rel="nofollow">Slang</a> spring to mind.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload