Use of setjmp()/longjmp() in code is typically a sign of laziness - and translates to "We didn't bother writing proper error handling". It's like using abort() but even worse. longjmp() out of the blue breaks the control flow of the application and easily leads to all kinds of resource leaks and state inconsistencies. The legitimate use cases for setjmp()/longjmp() are few and far between.#C #programming

all 3 comments

sorted by: hot top controversial new old
[–] 1 point 2 weeks ago

@harrysintonen back in the late 1990s I built a set of macros to get "exceptions" in C using setjmp/longjmp. In my defense I was young and inexperienced and this was never in a general use library.

  • source
  • [–] 1 point 2 weeks ago

    @harrysintonen funny, to me it translates to "here is another way to deal with error handling"it's close to your translation, there is less negativity thoughespecially useful with recursive functions/data structures

  • source
  • [–] [S] 1 point 2 weeks ago

    Classic example of using setjmp/longjmp for error handling:github.com/pnggroup/libpng/blo

  • source