Note that there are some explanatory texts on larger screens.

plurals
  1. POLong distance function call control
    primarykey
    data
    text
    <p>I have a function fun10() that I modified to a function fun11().</p> <p>A function fun1() calls fun2(), which calls fun3(), which calls, fun4(), ... and so on until fun9() calls fun10().</p> <p>Since I modified fun10() to fun11(), fun9() calls fun11() instead of fun10().</p> <p>However, I want to be able to choose whether I want to run fun10() or fun11(), based on my decision in fun1().</p> <p>The source code is distributed over multiple .c and .h files in multiple folders.</p> <p>Lots of C programming tricks are used, e.g. function pointers passed as arguments, opaque pointers to sub-structures in struct, struct and typedef in multiple levels, typecasting void pointers which are opaque handlers, tailq function iteration, back pointers, possible memory allocation for pointers etc.</p> <p>I tried using a global variable as a flag with extern but it doesn’t work (error ‘unknown symbol’) maybe because fun1() does not recognize fun10().</p> <p>Making a copy of every function in between seems too much especially when a function can contain hundreds of lines. I have a feeling this duplication is not good.</p> <p>I haven’t tried modifying the number of arguments such as changing fun3(a, b) to fun3(a, b, int flag=0). What side effects would it have?</p> <p>I am trying to squeeze the flag into one of the variables, which are often struct pointers, but it seems totally confusing because different struct pointers are passed from function to function. The final struct argument in fun10() ‘seems’ to be a subset of the struct argument in the original fun1() but it is contained inside a void pointer / opaque handler of the original struct definition.</p> <p>What is the solution?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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