1. 21

I linked my Snow testing library here on lobste.rs two days ago, and got a ton of great feedback, a lot of which I have incorporated into the library.

I figured it would be fun to write up some of the more obscure C features I learned about while writing the library.

  1.  

  2. 6

    GCC has a cleanup attribute that may be useful.

    1. 2

      https://gist.github.com/e160fdaffe84aede805f054a56466aa3

      related, this is an implementation of Andrei Alexandrescu’s SCOPE_EXIT (pretty much the same as defer in go) with gcc’s cleanup attribute and with clang blocks

      gcc’s version is cleaner and has no runtime overhead, gcc is able to optimize all of the complexity away in that simple case (usually also in more complex cases too)

    2. 1

      “Yes, the somelabel is a void *. Yes, we dereference somelabel to go to it. I don’t know how that works, but the important part is that it does”

      Well it is a pointer of type void, and you are not interested in its address but the addres it holds. If that’s weird, ever thought of char*s?