In my code, I have:
#define EV( event ) SendEvent( new event );
EV( evFormat );
But I want to pass a created object in the EV macro, like:
CEvent *ev = new CEvent();
EV( ev );
Is this possible? Because there is no way I will modify the EV macro.
The macro enforces that each call to
SendEventshould create a new dynamic object. Your problem is not just that using a macro for that is stupid and e.g. reduces the readability of your source code. It is also that the macro does not allow you to create the object earlier than the call, and that you can’t change the macro; in your words “there is no way I will modify theEVmacro”.The solution is therefore simple:
Don’t use the macro, use
SendEventdirectly, and remember to notdelete.