News for hackers. Stuff that matters.
Re:Some Obscure C Features by dkersten on Thursday August 22, 2019 @05:22PM (#20772480)
> It is also why C++ is not a strict superset of C

Can you explain? That code in C++ also scopes ‘a’ to the block.

EDIT: I see you’ve edited the code, but I think it’s still true in C++. I’ve often done that for RAII and unless I’m mistaken it works just as well when shadowing variables like you’re doing as when not.

Re:Some Obscure C Features by scott_s on Friday August 23, 2019 @11:22AM (#20778556)
Agreed. And I have also used it in C++ for RAII purposes. In C++, braces introduce a scope, and objects local to that scope will be destructed upon exit.