Skip to content

Support builds without exceptions#789

Merged
DenisBiryukov91 merged 1 commit into
eclipse-zenoh:mainfrom
oleid:allow_exception_free_build
Jul 2, 2026
Merged

Support builds without exceptions#789
DenisBiryukov91 merged 1 commit into
eclipse-zenoh:mainfrom
oleid:allow_exception_free_build

Conversation

@oleid

@oleid oleid commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

To be able to use zenoh-cpp in an exception free environment such as micro-controllers, the following minimally-invasive change provides a THROW_ZEXCEPTION macro, which compiles down to simply calling abort() if exceptions are disabled.

Since exceptions are the standard case, I think it doesn't make sense to change all the doxygen comments. I updated the documentation on error handling, though.

@oleid oleid force-pushed the allow_exception_free_build branch from d9dd20e to bd523a1 Compare July 2, 2026 09:37
@oleid

oleid commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

It would appear that the windows build is a bit unreliable. I don't see a way to trigger only the failed build. Maybe a maintainer can help.

Comment thread include/zenoh/api/base.hxx Outdated
@DenisBiryukov91

Copy link
Copy Markdown
Contributor

@oleid I'm wondering if it would be more appropriate to make zenoh::ZResult argument in every function mandatory in case exceptions are not supported, to prevent unexpected abort() calls.

@oleid

oleid commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@oleid I'm wondering if it would be more appropriate to make zenoh::ZResult argument in every function mandatory in case exceptions are not supported, to prevent unexpected abort() calls.

Sure, that would result in fewer surprises, however, would increase the diff considerably.
But if you prefer that solution, I'm happy to change the commit.

@oleid oleid force-pushed the allow_exception_free_build branch 3 times, most recently from 01f4bbd to 97491f5 Compare July 2, 2026 12:24
@oleid

oleid commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@DenisBiryukov91 Just checked. Trouble is: in most cases, there are optional arguments in front of the ZResult out-ptr. Therefore, the pointer must have a default value. And I can't change the order of arguments without breaking the API.

@oleid oleid force-pushed the allow_exception_free_build branch from 97491f5 to 1e16522 Compare July 2, 2026 12:32
@DenisBiryukov91 DenisBiryukov91 merged commit deca8b8 into eclipse-zenoh:main Jul 2, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants