r/C_Programming • • Aug 29 '26

Is the empty parenthesis function (() instead of (void)) prototype removed in the new standard?

My OOP library relies on it for its unspecified arguments behavior.

For example:

#define ptmethod(pt, ret_type, identifier) \
    (*((ret_type (**)()) padd(pt, identifier, ptfunction, NULL, NULL)))

#define ptapply(pt, ret_type, identifier, ...) \
    ((ret_type (*)()) pget(pt, identifier))(pt __VA_OPT__(,) __VA_ARGS__)

You could add a method to an object with:

void drive_Car(prototype *Car, double speed, double x_direction, double y_direction);

ptmethod(Car, void, "drive") = drive_Car;

and call it with

ptapply(Car, void, "drive", 1.3, 0.1, 5.0)

How do I do this in the new standard?

13 Upvotes

46 comments sorted by

View all comments

Show parent comment

2

u/torsten_dev Aug 30 '26 edited Aug 31 '26

Oh my god, you meant type erasure.

Yes, _Any_func is a form of type erasure, and it doesn't appear to be OP's intent to do that type of type erasure in his macros.

To be fair his macros are about as confusing as your comments, but I should have gotten your drift sooner. Sorry about that.

2

u/dstroy0 Aug 30 '26

No worries. I knew immediately the use case and specific problem the OP was trying to solve looking at the macro signatures. I didn't communicate that well at all and was an ass. I apologize.