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

Const-qualified parameters in exported functions #157

Open
pravorskyi opened this issue Oct 15, 2021 · 0 comments
Open

Const-qualified parameters in exported functions #157

pravorskyi opened this issue Oct 15, 2021 · 0 comments

Comments

@pravorskyi
Copy link

Hi! I wonder if there is any chance to make const-qualification of parameters in some exported functions?

For example, change cfg_getopt(cfg_t *cfg, const char *name); to cfg_getopt(const cfg_t *cfg, const char *name);.

This will allow to write more const (pure) functions, especially in C++ projects. However, it will be require to change the error reporting function prototype from:
typedef void (*cfg_errfunc_t)(cfg_t *cfg, const char *fmt, va_list ap);
to
typedef void (*cfg_errfunc_t)(const cfg_t *cfg, const char *fmt, va_list ap);

While I see no reason to change cfg_t data inside the callback for custom error reporting, I suppose there might be use cases for this. The above changes may also break backward compatibility. But the tests of this project pass successfully after such changes on my local machine.

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

1 participant