News for hackers. Stuff that matters.
Re:John Carmack on Inlined Code by dima55 on Friday September 26, 2014 @05:22PM (#8374956)
GCC has a (non-standard) extension where you can have nested functions:

https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html

This allows you to actually write what you want. Nicer still, these internal functions are aware of surrounding context, so they're full closures, and thus you can take their address and pass it around as a callback without needing any void* cookie. I've been using these more and more.

The downsides are that this is a nonstandard gcc-only extension and that it's available in C only, not C++. Depending on what you're doing, these can be deal-breakers.

Re:John Carmack on Inlined Code by gdwatson on Friday September 26, 2014 @06:12PM (#8375175)
My brain has taken to interpreting "GCC extension" as "supported by GCC and Clang," but nested functions are one of the few cases where that isn't true,[1] which is worth noting for readers who are concerned about FreeBSD or OS X.

[1] http://clang.llvm.org/comparison.html#gcc

Re:John Carmack on Inlined Code by _delirium on Friday September 26, 2014 @06:46PM (#8375286)
Fwiw there's no real problem with gcc-specific code on FreeBSD if you're writing application software. Kernel code and core utilities in the base install are supposed to be able to compile with clang, but stuff in ports can use anything that is itself available in ports. The ports system makes it easy to specify when something requires gcc to compile vs. any C compiler, and doing so is fairly common (heck, it's not a problem to require even more exotic things either, like Ocaml or gfortran).