Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About exceptions handling #153

Closed
Bolderaysky opened this issue Feb 3, 2023 · 4 comments
Closed

About exceptions handling #153

Bolderaysky opened this issue Feb 3, 2023 · 4 comments

Comments

@Bolderaysky
Copy link

I found that glaze is throwing exceptions by default. First looking at the code and repo, I find that glaze doesn't support exception-free mode. Is it possible to implement that for using glaze in projects with no exceptions?

glaze/include/glaze/util/parse.hpp:262:48: error: exception handling disabled, use ‘-fexceptions’ to enable
  262 |          throw std::runtime_error("not a digit");
@stephenberry
Copy link
Owner

Yeah, we currently don't have a no exception option for JSON. Binary reading/writing doesn't throw errors, as it expects proper data generated from the library.

We plan to implement a no exception compile time option for JSON, but there is actually a performance loss when going to another error handling approach (exceptions allow us to reduce the number of branch checks). We also want to make sure we're not over complicating the code base and have a good implementation. But, I have an idea I'll experiment with.

Do you have a target platform that doesn't allow exceptions?

Thanks for bringing this up and hopefully it will be tackled soon.

@Bolderaysky
Copy link
Author

Thanks for your answer!

Mainly, these platforms are Linux and macOS, where I disable exceptions and do everything explicitly.

It is possible to work around that by compiling a part of the project that uses Glaze as a shared library and only use exceptions in that library. However, it would be great to see such an opportunity in Glaze, since there are platforms where the use of exceptions is not allowed at all.

@stephenberry
Copy link
Owner

Yeah, we want to be able to build on embedded hardware in the future, so disabling exceptions is required. Thanks for the encouragement to work on this.

@stephenberry
Copy link
Owner

@Bolderaysky The no_except branch (#156) has been merged, so you can now build with -fno-exceptions

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

No branches or pull requests

2 participants