News for hackers. Stuff that matters.
Re:Emulating Swift's “defer” in C, with Clang or GCC+Blocks by raimue on Saturday October 10, 2015 @01:13PM (#10366141)
What purpose does the empty do{}while(0); statement serve here?
Re:Emulating Swift's “defer” in C, with Clang or GCC+Blocks by gp7 on Saturday October 10, 2015 @01:17PM (#10366154)
It puts the whole #define code into a single expression so you can do

  if (cond)
    MACRO;
and the macro won't expand incorrectly to

  if (cond)
    foo;
  bar;
I personally just go the anal retentive route and use brackets everywhere.
Re:Emulating Swift's “defer” in C, with Clang or GCC+Blocks by cthrowappp on Saturday October 10, 2015 @01:58PM (#10366288)
Not in this case it doesn't.
Re:Emulating Swift's “defer” in C, with Clang or GCC+Blocks by geocar on Saturday October 10, 2015 @01:35PM (#10366207)
No syntax error if someone writes if(x)defer. Probably better to have a big error message since we can't curry the if.

if(x){defer} will be wrong, but it'll be wrong in a different way.