Home > Back-end >  One problem: space of the STL source code parsing configurator chapters: the first level configurato
One problem: space of the STL source code parsing configurator chapters: the first level configurato

Time:12-01




What is the meaning of this??

CodePudding user response:

Set the function Pointers, the return value is a function pointer, the parameter is a function pointer as well

CodePudding user response:

Void * (f) (a) declare a function pointer variable f

F now is not a variable, but a function return values, which consider f set_malloc_handler () returns a value, that is
Void (* set_malloc_handler () ()

Further, set_malloc_handler function and a parameter, this parameter is void (*) () function pointer parameter, argument is f, finally is
void (* set_malloc_handler ( void * f () () ()

For the main body function set_malloc_handler, its parameters and the type of the return value is the same, is a function pointer type void (*) (),
This kind of writing's hard to understand for beginners,

Should use the typedef is better,

 

Malloc_handler typedef void (*) ()

The static malloc_handler set_malloc_handler (malloc_handler handler) {

}


CodePudding user response:

F above should be parameter, wrong

CodePudding user response:

 void fun (int b) {

}
Void (*/set/function name (/here/) function parameters) (int//return a function pointer, the required parameters) {
Return the fun;
}
Int main (void)
{
Void (* p) (int)=set ();
P (10);

}

CodePudding user response:

Now know that the return value is a function pointer, the function pointer requires to function is a void fun () is also return a no return value functions; Expand, if return a pointer to the function of need to return a pointer to a function how to write?
That is to say, return a pointer to a function return a pointer to function, how to write?
  • Related