I like to voverload a C function. I found following: Function overloading in C using GCC - functions with mutiple arguments. This works very fine, but now i want to sellect the function based on the type of two arguments.
#define dataioWriteBin(file, data, len) \
(__builtin_choose_expr(__builtin_types_compatible_p(typeof(*data), uint8_t ) && __builtin_types_compatible_p(typeof(len), uint64_t ), dataioWriteBin_uint8Data_uint64Len, \
__builtin_choose_expr(__builtin_types_compatible_p(typeof(*data), uint8_t ) && __builtin_types_compatible_p(typeof(len), uint32_t ), dataioWriteBin_uint8Data_uint32Len, \
__builtin_choose_expr(__builtin_types_compatible_p(typeof(*data), uint32_t ) && __builtin_types_compatible_p(typeof(len), uint64_t ), dataioWriteBin_uint32Data_uint64Len, \
__builtin_choose_expr(__builtin_types_compatible_p(typeof(*data), uint32_t ) && __builtin_types_compatible_p(typeof(len), uint32_t ), dataioWriteBin_uint32Data_uint32Len, \
(void)0))))(file, data, len))
But with this code i got a compile following error:
error: called object is not a function or function pointer (__builtin_choose_expr(__builtin_types_compatible_p(typeof(*data), uint8_t )
Anybody a Idea, is it not possibel to dispatch on two argumnents. The construct itself does also work. It Fails wenn i call the function with uint32_t data and uint32_t length. The Function calls with uint8_t are working.
Thanks for your help.