Trying to overloading a function in C programming language with _Generic
. Have found examples:
This the example:
#include <stdio.h>
#include <math.h>
void display_float(float dispid) ;
void display_int(int dispid) ;
void display_void(void) ;
#define display(x) _Generic((x), \
float: display_float, \
int: display_int, \
default: display_float \
)(x)
void display_void(void){
printf("display id: 0\n") ;
}
void display_float(float dispid){
printf("display id: %f\n", dispid) ;
}
void display_int(int dispid){
printf("display id: %d\n", dispid) ;
}
void main(void){
display(5) ;
display(6.5) ;
}
Now I also want to overload the function with display()
. Meaning the function would intake a void
, call the function display_void()
, and display 0. Can't seem to do this. Any help would be appreciated.
EDIT 1:
Also, see the examples here. One of the examples (I think) is passing a pointer to a void. Can this be implemented?