Closed
Description
The public API allows the same functions to be used on different kinds of objects. This makes it pretty error-prone: it's easy to call a function on an invalid type without any compile-time error (either an aml type not accepted by the function in which case it's a runtime error, or a completely foreign type in which case it's just fireworks). C11 _Generic
could be used to indicate which types are accepted by a function, e.g:
int _aml_get_fd(const void* obj);
#define aml_get_fd(obj) _Generic(obj, \
const struct aml*: _aml_get_fd, \
const struct aml_handler*: _aml_get_fd, \
)(obj)
(Note that in general I am not a fan of functions accepting multiple types of arguments, and would just recommend duplicating the functions into multiple wrappers.)
Metadata
Metadata
Assignees
Labels
No labels