Skip to content

Add support for -fno-exceptions #247

@void2012

Description

@void2012

I want to thank you @tcbrindle for this amazing library! I find it way easier to use than std::ranges. However, I have a platform that has no exceptions support. And want to reuse my flux code here, but it doesn't compile because of exceptions.

There are only two places where C++ exception handling is used:

auto flux::generator<ElemT>::promise_type::unhandled_exception() 
{ throw; } 

void flux::detail::runtime_error_fn::unwind(const char* msg, std::source_location loc)
{
        char buf[1024];
        std::snprintf(buf, 1024, "%s:%u: Fatal error: %s",
                      loc.file_name(), loc.line(), msg);
        throw unrecoverable_error(buf);
}

As there are no try-catch clauses in the library, I think it's safe to use either std::terminate or __builtin_trap as a -fno-exceptions alternative. Please add a check for -fno-exceptions with something like __cpp_exceptions or __EXCEPTIONS
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions