Hacker News new | ask | show | jobs
by 8_hours_ago 4510 days ago
A very important gotcha with this approach is that any variable named "i" will be reset to 0 inside of the lock, and modifying "i" inside of the lock can cause an infinite loop.

This can be mitigated by generating a unique variable name with the C preprocessor: http://stackoverflow.com/questions/1132751/how-can-i-generat...

That being said, it's much better to use a standard method of scoped locking instead of trying to reinvent the wheel.