why while(0)
mmj-the-fighter opened this issue · comments
Manoj M J commented
Please explain the rationale behind keeping the following pattern in the code
do{
...
} while (0)
Manoj M J commented
i replaced do{ ... } while(0) with {..} for #define cvector_push_back(vec, value) , and it worked.
Evan Teran commented
The rationale is that it is a common pattern to ensure that the code properly acts like a function call.
For example, you'll notice that the do while version requires a semicolon but yours does not.