Skip to content

The signature of void* fxn in filter needs to be defined

https://gitlab.com/Mandarancio/microrx/blob/master/src/basics.h#L51

Basic type checking can be provided by defining the function type elsewhere such as

typedef bool (*filter_fxn)(stream*)

This should reduce debugging by forcing the compiler to catch the issue instead of hoping programmers read the API

On that note, I think filter might be better served by defining it's behavior to support

typedef void* (*filter_fxn)(stream*) as this would allow digital filters, like FIR, IIR, etc. to be incorporated. One of the issues that plagues embedded programmers is the ambiguity of nomenclature. Are they computer scientists? In that case a boolean filter makes sense. Are they electrical engineers trying to get a PCB up and running, logging a noisy voltage line? Digital filtering will be much more useful.

Of course, this is your API, maybe you want both to be supported, that's your call. But I think that leaving that filter undefined, and hoping that programmers use it right will lead to more problems than it's worth.

Edited by Alex Shirley