Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In C GOTO is often by far the cleanest solution for error handling.

Everything else turns into an ugly, unreadable mess in functions that need to free resources or do some kind of cleanup.



I've seen the goto error-handling approach used now in SDKs written by developers from companies like Microsoft, Nvidia, and Nordic Semiconductor. It really does seem to be the best way to do it. And it's simple. Mess something up... goto cleanup... Seems fine to me!


My comment has nothing to do with error handling. I was addressing a false claim about performance.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: