#include #include #define template_function_name(type) \ function_##type #define template_function_declare(type) \ type function_##type(type a, type b) \ { \ return a + b; \ } #define template_function_internal(type) \ type: template_function_name(type) template_function_declare(int); template_function_declare(float); template_function_declare(double); #define function(a, b) \ _Generic( \ a, \ template_function_internal(int), \ template_function_internal(float), \ template_function_internal(double) \ )(a, b) int main(void) { printf("`int` + `int` = %d\n", function(10000, 10000)); printf("`float` + `float` = %f\n", function((float)10000.0, (float)10000.0)); printf("`double` + `double` = %f\n", function(10000.0, 10000.0)); return EXIT_SUCCESS; }