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

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

Open
manowicz opened this issue Jun 1, 2021 · 0 comments

Comments

@manowicz
Copy link

manowicz commented Jun 1, 2021

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
Projects
None yet
Development

No branches or pull requests

2 participants