I recently found out that it is legal C:
#include <stdio.h> int foo(int bar(int)) { return bar(42); } int bar(int x) { return x * 42; } int main() { printf("Baz = %d\n", foo(bar)); return 0; }
Compiles without warnings and works as expected (compiles and works fine even in a C program, not in C ++)
rep ~/Documents $ g++ -Wall test.cpp rep ~/Documents $ ./a.out Baz = 1764 rep ~/Documents $
Why is this syntax not used more often or not even mentioned anywhere?
source share