I'm glad to see that setjmp() and longjmp() are still allowed. I'm just kidding by the way. For those C programmers who haven't encountered these before, it is a powerful way to do a "goto" in C. Powerful in the sense that you can jump anywhere, not limited to the same function. If it's used at all these days, it's used for exception handling. More info: https://en.wikipedia.org/wiki/Setjmp.h
I've always wondered why goto is actually considered harmful. I really should read the original paper by Djikstra...
Banned C standard library functions in Git source code
151–160 of 329 posts
Re: Banned C standard library functions in Git source code
#152Earlier quoted context omitted.
It encourages spaghetti code.
Not using it can also create spaghetti code. For example the "alternatives" often suggesting for exiting a multi-tiered loop (which often add additional boilerplate, additional variables, etc that all need to be maintained/bug free).
Re: Banned C standard library functions in Git source code
#153> strcpy ... BANNED But they cannot ban while (* p++ = * q++); now can they.
Re: Banned C standard library functions in Git source code
#154Re: Banned C standard library functions in Git source code
#155Earlier quoted context omitted.
Here is an implementation of coroutines on top of setjmp/longjmp: https://fanf.livejournal.com/105413.html
Looks more like an implementation of undefined behaviour to me.
Re: Banned C standard library functions in Git source code
#156Puts(),gets() would make a good addition?
Re: Banned C standard library functions in Git source code
#157Earlier quoted context omitted.
Every C programmer has his/her own standard library...
I wonder about this every time I read C. There is talk about npm/rust having massive dependency trees (and they do) because it makes taking on dependencies too easy. But I feel like C is on the opposite side of the spectrum, where managing dependencies is difficult so every C code base is rolling it’s own version of everything. C also has an expansive standard library but it hasn’t offset re-invention of that stdlib…
One reason, I guess, is the diverse range of applications of C, another reason is the lack of advanced features like generics and templates.
But it would still be useful to create a simple library, intended for Unix-like platforms (beyond the BSD extension of stdlib). So it's more of a cultural problem?
Re: Banned C standard library functions in Git source code
#158musl libc (an alternative libc) provides implementations of these functions that are memory-safe. (It only works on Linux though.)
Using musl as your standard library causes other problems, namely horrible Python performance and incompatibility with Valgrind.
Re: Banned C standard library functions in Git source code
#159Re: Banned C standard library functions in Git source code
#160Earlier quoted context omitted.
Every C programmer has his/her own standard library...
I wonder about this every time I read C. There is talk about npm/rust having massive dependency trees (and they do) because it makes taking on dependencies too easy. But I feel like C is on the opposite side of the spectrum, where managing dependencies is difficult so every C code base is rolling it’s own version of everything. C also has an expansive standard library but it hasn’t offset re-invention of that stdlib…