Code :
#include <stdio.h> int FooChr(char a, char b) { fprintf(stderr, "(char) version\n" ); } int FooPtr(char * a, char * b) { fprintf(stderr, "(char *) version\n" ); } int FooChrPtr(char a, char * b) { fprintf(stderr, "(char, char *) version\n" ); } #define Foo(a, b) _Generic(a, int: _Generic(b, int: FooChr, char *: FooChrPtr), char *: FooPtr)(a, b) int main(int nb, char * argv[]) { char * a = NULL; Foo('a', 'b'); // FooChr Foo(a, a); // FooPtr Foo('a', a); // FooChrPtr return 0; }
|