The + notation in fun hooks (for converting a function that manipulates a fresh pointer, to one that does the allocation itself and returns the pointer) is to my mind one of the nicest features of c2hs. Unfortunately, it discards the original return value, making it useless in the case where the C function returns something useful eg. an error code, and we want to return that result along with the pointer.
It would be amazing (and presumably not that difficult to implement, I may even look at submitting a PR) if we could specify that we would like a tuple returned, and have c2hs do the obvious conversions.
eg. {#fun cfunc as ^ {+} -> `(aPtr, b)' #}
for b cfunc (x *a)
The
+
notation infun
hooks (for converting a function that manipulates a fresh pointer, to one that does the allocation itself and returns the pointer) is to my mind one of the nicest features of c2hs. Unfortunately, it discards the original return value, making it useless in the case where the C function returns something useful eg. an error code, and we want to return that result along with the pointer.It would be amazing (and presumably not that difficult to implement, I may even look at submitting a PR) if we could specify that we would like a tuple returned, and have c2hs do the obvious conversions.
eg.
{#fun cfunc as ^ {+} -> `(aPtr, b)' #}
forb cfunc (x *a)