I stumbled over a weird piece of code that I thought would not work the way it is intended, but it did. Example:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("%d\n", abs(-1)); // output: 1
printf("%d\n", (abs)(-1)); // output: 1
return 0;
}
Apparently putting parenthesis around the function name in a function call has no effect on the program. It just makes it look like a cast.
I am kinda interested if this is defined somehow. But I figure that it just not forbidden and that's why it works.
What I am really curious about is, is there a case where this kind of notation might yield an advantage in any kind? (structure of the code, readability, anything this might be useful for)
Or is it just a "weird" way to write code?