[sane-devel] Using C++ in sane backends

Povilas Kanapickas povilas at radix.lt
Fri May 10 22:00:34 BST 2019

On 2019-05-09 11:56, Povilas Kanapickas wrote:
> I would propose we allow C++, but that its use must not affect API or
> ABI in any way. There should be a hard requirement that there must be no
> visible changes outside a specific backend, except the need to link the
> backend with libstdc++.

As a concrete example of what the proposal would entail I've opened this
PR which moves genesys backend to C++:


Total PR excluding generated files and spaces is only ~55 lines: around
40 lines of extern "C" definitions in the internal headers and 15 lines
of changed code in the build system.

Two benefits that would yield almost immediate improvements are the

 - ability to use exceptions instead of manual error handling which
currently often explodes the amount of code by 4 times.

 - using simple C++ idioms to automatically free memory on function
exit. This would essentially eliminate 95% of potential sources of
memory leaks in the backend. I've just fixed one recently, so it's
indeed an issue.


More information about the sane-devel mailing list