callback function without brackets??

Hi Guys,
I met a little problem when I looking into the library of ESP32 library:

there is a call back function onEvent():

wifi_event_id_t WiFiGenericClass::onEvent(WiFiEventCb cbEvent, system_event_id_t event)
{
    if(!cbEvent) {
        return 0;
    }
    WiFiEventCbList_t newEventHandler;
    newEventHandler.cb = cbEvent;
    newEventHandler.fcb = NULL;
    newEventHandler.scb = NULL;
    newEventHandler.event = event;
    cbEventList.push_back(newEventHandler);
    return newEventHandler.id;
}

the argument cbEvent is an object of function type WiFiEventCb, which is defined as this:

typedef std::function<void(system_event_id_t event, system_event_info_t info)> WiFiEventFuncCb;

my question is that, the argument cbEvent is a pointer to a callback function thus it has to contain brackets in the implementation of the calling function onEvent() to invoke the callback function, but in the implementation of onEvent(), the cbEvent doesn't have brackets.

As I know, if we want to invoke a function, we have to add brackets after the name of a function, but in library why the cbEvent doesn't have brackets but the calling function onEvent() can still invoke its callback function in arduino IDE?
I hope you can take time out of your busy schedule to help me,
Kind regards,

the function is passed as argument, not the result of the function call.
name of the function is a pointer to the function. with () it is an execution of the function

The wording of your question is confusing. But, I'll take a shot at what I THINK you mean and reply: When passing function pointers as arguments to functions, you don't include the parenthesis.

Juraj:
the function is passed as argument, not the result of the function call.
name of the function is a pointer to the function. with () it is an execution of the function

Yes I know the function is passed as argument, but the arduino IDE can let the callback function execute without (), that's the weird thing I want to ask

peter_chen:
Yes I know the function is passed as argument, but the arduino IDE can let the callback function execute without (), that's the weird thing I want to ask

It can do no such thing.

The function isn't being called when you pass it as an argument.

The function you quoted shows the pointer to the callback function being stored in "newEventHandler.cb". The execution of the callback function is in the event handler code, somewhere else in the library. THAT is where the "()" is used to call the callback function. Look for other places where ".cb" is used.

TheMemberFormerlyKnownAsAWOL:
It can do no such thing.

The function isn't being called when you pass it as an argument.

I'm not joking, it really happened,
First I defined a function WiFiEvent:

void WiFiEvent(WiFiEvent_t event) {...}

inside the implementation of WiFiEvent, there is a lot of Serial.println() functions.
then I make the WiFiEvent as the argument of calling function onEvent:

WiFi.onEvent(WiFiEvent);

the result is that the callback function WiFiEvent executed well and all Serial.println() are executed as well.

Do you understand what a callback is supposed to do?

peter_chen:
I'm not joking,

No, you simply don't know what you're talking about.

gfvalvo:
No, you simply don't know what you're talking about.

Sorry I'm not familiar with some terminologies, But I think you maybe understand what I mean

peter_chen:
Yes I know the function is passed as argument, but the arduino IDE can let the callback function execute without (), that's the weird thing I want to ask

No it does not. The onEvent function is not executing the callback function. It is pushing the callback function (and its associated event id) onto a list of callbacks for the library to use.

Broadly speaking, the WifiGenericClass library must be designed so that certain events are automatically handled by the library. When one of these events happen, it looks through the cbEventList to see if any callback functions have been registered for that event. If there is any, it executes them to handle the event. onEvent is not executing the function, it's simply adding it to the list so that it will be called the next time that event happens.

Jiggy-Ninja:
No it does not. The onEvent function is not executing the callback function. It is pushing the callback function (and its associated event id) onto a list of callbacks for the library to use.

Broadly speaking, the WifiGenericClass library must be designed so that certain events are automatically handled by the library. When one of these events happen, it looks through the cbEventList to see if any callback functions have been registered for that event. If there is any, it executes them to handle the event. onEvent is not executing the function, it's simply adding it to the list so that it will be called the next time that event happens.

Thanks man you helped me a lot, have a nice day

johnwasser:
The function you quoted shows the pointer to the callback function being stored in "newEventHandler.cb". The execution of the callback function is in the event handler code, somewhere else in the library. THAT is where the "()" is used to call the callback function. Look for other places where ".cb" is used.

Thanks sir you helped me a lot

"Report to moderator is not a "REPLY" button.

Bob.

The REPORT TO MODERATOR is still not a REPLY button no matter how many times you press it.

Bob.