Comment

Comment by teddyh

Not a builtin, but a GCC feature which has improved my C code hugely is __attribute__((cleanup)). It is used to specify a destructor for a local variable; when the variable goes out of scope the function is called with a pointer to the variable as an argument.

Example:

  {
    __attribute__((cleanup(foo)))
      int a;
      …
     /* foo(&a) will implicitly be called here */
  }
parent teddyh 7 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton