cisco / mlspp

Implementation of Messaging Layer Security
BSD 2-Clause "Simplified" License
110 stars 42 forks source link

Support building without exceptions/RTTI #353

Closed birarda closed 1 year ago

birarda commented 1 year ago

Hello!

I'd like to use this in a project with no-rtti and no-exceptions. It would great if there was an option to compile avoiding exceptions and the dynamic_cast usage.

I'm happy to prepare that and send a PR, but I think some guidance for how you'd want the no-exception error handling to look is needed.

bifurcation commented 1 year ago

Hi @birarda - I think either of these would be pretty challenging.

Getting rid of dynamic_cast would require some nontrivial refactoring in the hpke module. But it is a fairly limited number of call sites, so if you have suggestions, I would be open to them.

Getting rid of exceptions would require changing basically every method signature in the whole project, so I would be pretty skeptical of doing something here. For better or worse, exceptions are the native C++ error-handling scheme, since the language lacks tools like Rust or Go have cleanly accommodating error return values.

birarda commented 1 year ago

Hey @bifurcation - thanks for your response.

I think we'll be able to deal with both of these from our wrapping library, so I'm happy to close this.

I think it would be nice eventually to have the option to retrieve error codes instead of the exceptions (since this would be nicer for the calling library to deal with instead of a catching wrapper), but I take the point that they are pervasive in the project and are unfortunately the most native thing we have in C++.