2

I am trying to store and use a pointer to a global function. The function global_f returns a String and takes an object as parameter:

String global_f(Request r){
    // ...
    return "This is it";
}

I have also declared a type:

typedef String (*f_type)(Request);

And this is the class that stores the function:

class T {
    f_type f;

    void setF(f_type fFunc){ // called as: setF(&global_f)
        f = fFunc;
        f(Request());        // This Works
    }

    void callF(){
        f(Request());       // This Freezes the arduino
    }
}

So I can call f in the instructor, but it freezes the Arduino in other methods.

Follow-up: It runs in all methods, that the function is being passed as a parameter and stored in the object. This is where this functions is called in the actual code: GitHub

Kostas C.
  • 21
  • 2

0 Answers0