I found this code and I understand what it does (prints if var is type of float) but I can't understand how:
#include <stdio.h>
#include <stdlib.h>
#define typename(x) _Generic((x), float: "float")
#define isCompatible(x, type) _Generic(x, type: true, default: false)
int main(){
float var;
if(isCompatible(var, float))
printf("var is of type float!\n");
}
What is typename(x)? Why is never called? Also I can't understand this construct:
_Generic(x, type: true, default: false)
And here is there a way to not pass float as parameter and make it implicit?
if(isCompatible(var, float))