I want to make a function to choose another one in C, maybe this C-pseudo code can help a little to clarify what I want:
void set_method(const char *method)
{
// Check if the method is serial_port
if (strcmp(method, "serial_port") == 0)
{
// assign the alias "print" to serial_print
// something like defing here a function like this:
// print(const char *print) { serial_print(print); }
print(const char *print) = serial_print(const char *message)
}
else if (strcmp(method, "graphical_tty") == 0)
{
// The same that serial_port case but with graphical_tty_print
}
else
{
// Error
}
}
The goal is to assign an "alias" to a function if the condition is met, how can I do this?
I'm using a freestanding C implementation for this, compiled with clang.