Thanks a lot for all your hard work on this! In coordination with the book “Learn cocos2d 2” and the tutorials, I’m starting to get the hang of it. I just got the HelloCpp and TestCpp applications running on my Android tablet. This was a big step for me because I’m using Ubuntu Linux but had some build errors to sort through in Eclipse due to using a 64-bit OS. Anyhow, I’m just curious about something. I’ve seen ‘do { … some code … } while(0);’ frequently in the cocos2d framework code. Why surround code with this when it doesn’t do anything?

We have a cleanup phase and make sure each local variables are ok, they won’t make memory leak. Also make sure some must-be logics for failure will be run.Each function has only one return point, that is very important. It will make code review easier, and adding profilers are easier too. I think no one like to add profiler like this

So far, the defensive programming work ok in C/C++. Then we meet another problem, scripting languages has no “goto” instruction.That’s why do {} while(0) is here. We use “break” instruction to do the job of jummping.