Skip to content

Handler error code type (enum) doesn't match the return type of handlers (int) #243

Description

@manowicz

Handlers like readstat_set_variable_handler return an integer error code, but the three available error codes are defined as an enum:

enum {
    READSTAT_HANDLER_OK,
    READSTAT_HANDLER_ABORT,
    READSTAT_HANDLER_SKIP_VARIABLE
};

As a result when registering a handler as a lambda function, I need a cast to avoid compilation errors:

readstat_set_variable_handler(parser, [](int, readstat_variable_t*, const char*, void*) {
           return static_cast<int>(READSTAT_HANDLER_OK);
});	

While it would make sense to be able to write:

readstat_set_variable_handler(parser, [](int, readstat_variable_t*, const char*, void*) {
           return READSTAT_HANDLER_OK;
});	
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions