5 ms·
GNU C is probably my favorite extension of C. There's a lot of good stuff in there. The vector extensions make it really easy to write platform agnostic SIMD co
by castratikron 9y ago
GNU C is probably my favorite extension of C. There's a lot of good stuff in there. The vector extensions make it really easy to write platform agnostic SIMD code.
https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
- blattimwind 9y agoI've used nested functions more often than I'd like to admit, because dealing with insane callback-heavy APIs is made a lot easier with them.
- s73v3r_ 9y agoI've never really thought to use nested functions for that. I guess I've never really thought of what nested functions were for.
- gmueckl 9y agoWelcome to the lambda party ;). Passing nested functions as pointers is how lambdas often work behind the scene.
- Roboprog 9y agoThose of us who had nested functions/procedures and “procedural types” in Pascal (or Algol, but that’s beyond my experience) back in the day have :-) Then K&R came, and took our nice toys away. Fortunately, the GNU Pascal compiler needed nested subroutines, so they exposed the feature in their C compiler, as well.
- pjmlp 9y agoAnd now even C# has them. :) On C++ we can fake them with lambdas.
- Gibbon1 9y agoI love using nested functions when I have to write state machine code. It's a hella a lot better than the old school way using macros to do the same thing.
- kerkeslager 9y agoAlso, the compare-and-set operations enabling lock-free code is pretty cool.
- Sir_Cmpwn 9y agoPlease don't use GNU C, or any other non-standardized version of C. A huge part of the reason C that is so widespread is because it's a well defined standard implemented by many compilers for many platforms. GNU C is defined by its implementation, which is awful.
- emilfihlman 9y agoThere is nothing wrong with using GCC extensions. Also, porting C is not that hard and does not require you to touch internals that much.
- jcelerier 9y ago> Please don't use GNU C, or any other non-standardized version of C. Everything standard was once non-standard ; if no one uses it it will never be standardised and we will be left with a poor status quo. For instance, there wouldn't be int8_t, etc... if people weren't using non-standard macros beforehand. Likewise for atomics, threads, etc.
- exDM69 9y agoI disagree with this. A lot of GNU C works on both, GCC and Clang which covers most platforms out there. Those extensions are useful and allow better portability across architectures. E.g. SIMD extensions is much better than writing two implementations with NEON and SSE intrinsics.
- pcwalton 9y agoPlease do use GNU C if you're going to use C. The viral nature of the Linux kernel has forced GNU C to be an important de facto standard. Take advantage of that!
- pjmlp 9y agoGoogle has taken the effort to make Linux compile with clang, as part of their efforts to wipe gcc from Android toolchain. There is a LLVM talk about it. However I do agree with you. clang and gcc cover most of the systems that matter today and their C extensions definitely make C a safer language.