tags:

views:

119

answers:

2

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();

+4  A: 

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.

AraK
+4  A: 

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 :)

sergiom