News for hackers. Stuff that matters.
Re:I ruined my vacation by reverse engineering WSC by Asooka on Monday May 12, 2025 @09:09AM (#43962511)
Why did you write it with two structs though? You could do

    #define defer(body) DeferHolder COMMON_CAT(_defer_instance, __LINE__) {([&]()->void body)};
and call it as

    defer({
        function body here;
    });
Which looks much nicer. The preprocessor treats balanced curlies as one single token regardless of how many lines it spans, precisely to enable this usage.

There are no comments on this comment yet.