Messages in this thread | | | Date | Wed, 13 May 2015 15:19:03 +0300 | Subject | Re: [PATCH 02/12] Add parse_integer() (replacement for simple_strto*()) | From | Alexey Dobriyan <> |
| |
[Answering to Noel Grandin, gmane sent email to list only]
> > int parse_integer(const char *s, unsigned int base, T *val); > > > > I suspect splitting this into > parse_signed_int > and > parse_unsigned_int > (or some other equivalent names) > will make the call-sites a lot easier to read.
parse_integer() is about two and only two points (everything else is immaterial and technical details): 1) unified interface, 2) automatically fixing overflow bug based on type T.
Two interfaces in this situation is no different from having four.
C doesn't have generic functions so programmers get hardwired to million of names all doing roughly the same but __b_c_e and _Generic allows to mimic generic functions which is at least something.
| |