Why sometimes C code gets wrapped with curly braces without declaring a variable in them?
e.g. (from FreeRTOS source code, file 'tasks.c'):
portENTER_CRITICAL();
{
xTicks = xTickCount;
}
portEXIT_CRITICAL();
This is just an inner scope. The benefit is that code shows your intent in that case. e.g. This scope is the critical section.
There is no need to use curly braces like this, but it helps readability.
It's a choice of style by the author, I suppose :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With