News for hackers. Stuff that matters.
Re:Emulating Swift's “defer” in C, with Clang or GCC+Blocks by azinman2 on Saturday October 10, 2015 @05:52PM (#10367140)
Can you explain more please?
Re:Emulating Swift's “defer” in C, with Clang or GCC+Blocks by copascetic on Saturday October 10, 2015 @06:08PM (#10367180)
Because a macro in C/C++ is just text expansion, the given implementation will evaluate its arguments more than once, which will not be obvious at the "call" site and could have unintended consequences if the expressions have side-effects.
Re:Emulating Swift's “defer” in C, with Clang or GCC+Blocks by azinman2 on Tuesday October 13, 2015 @01:58AM (#10378760)
Is there another way to do it as a macro that avoids this? How do you have temporary variables potentially in the middle of a larger expression, e.g. if (min(a,b) == 3) {...}