attractivechaos / klib

A standalone and lightweight C library
http://attractivechaos.github.io/klib/
MIT License
4.18k stars 556 forks source link

C++ compatibility: invalid conversion from ‘const char*’ to ‘char*’ in ketopt.h #122

Closed dnbaker closed 5 years ago

dnbaker commented 5 years ago

It's a small change, but I'd simply like to request that char *p here (https://github.com/attractivechaos/klib/blob/master/ketopt.h#L92) be replaced with const char *p to allow compilation with C++ because of its stricter perspective on const-correctness.

Example compiler output:

klib/ketopt.h: In function ‘int ketopt(ketopt_t*, int, char**, int, const char*, const ko_longopt_t*)’:
klib/ketopt.h:95:13: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
   p = strchr(ostr, opt);

Thank you!

attractivechaos commented 5 years ago

Please send a pull request. I will merge. Thanks!