|
|
|
|
|
by LegionMammal978
465 days ago
|
|
A more practical way (short of explicit language support) would be to have an enum and a dispatcher function: enum { CALL_Z, CALL_W };
int call_z_or_w(int which, int arg) {
switch (which) {
case CALL_Z: return z(arg);
case CALL_W: return w(arg);
default: __builtin_unreachable();
}
}
Or you could even do the same thing, but switching on the pointer value instead of an enum. Either way, this lets the compiler statically know where the call may possibly lead to. |
|