Home > Back-end >  The callback function compiled through
The callback function compiled through

Time:11-20

So a piece of code, didn't compile, MSVC, g + + is not through, look not to understand,,
G + + an error: invalid conversion from "void (*) (void *, int * (*) (), int, int) 'to' void (*) (void *, int, int, int) [- fpermissive]
'Please give an explanation of the ~

 # include & lt; Iostream> 


Call_back typedef void (*) (void *, int, int, int).

Void GetProcess (call_back cb, void * cb_class)
{
Float process=0.8;

If (cb)
{
Cb (cb_class, 0, 1, 1);
}
}

Void callback (void * cl, int errno, int a, b int)
{
Printf (" % d \ n ", errno);
}


Int main (int arg c, char * * argv)
{
GetProcess (callback, nullptr);

return 0;
}

CodePudding user response:

Parameter int errno change a name, errno is a macro

CodePudding user response:

In fact have to remind you, void callback (void * cl, int errno, int a, int b); The errno is red, it's a red, you define the variable names and the inside of the c + + macro repeated

CodePudding user response:

Change. C, GCC compiler no problem,
.cpp, g + + compiler has a problem, it seems the g + + check too cattle,
  • Related