Unless I&#x27;m mistaken, `__attribute__((cleanup))` is function-, not block-, scoped.  The cleanup attribute is actually declared on the Block, which is kind of cute.<p>Instead, I&#x27;d suggest just making regular use of `__attribute__((cleanup))` in C under GCC or Clang and avoiding C blocks entirely.  In this case you could do something like:<p><pre><code>  #define AUTOCLOSE_FILE(n) __attribute__((cleanup(autoclose_file))) n = NULL
  
  void
  autoclose_file(FILE *f)
  {
    if (f)
      fclose(f);
  }
  
  int
  main(...)
  {
    FILE AUTOCLOSE_FILE(*a), AUTOCLOSE_FILE(*b);
  
    a = fopen(&quot;foo&quot;);
    if (!a)
      return;

    b = fopen(&quot;bar&quot;);
    if (!b)
      return;
  
    ...
  }</code></pre>