Curly braces without variable declarations

Why is sometimes C code wrapped in curly braces without declaring a variable in them? for example (from the source code of FreeRTOS, the file 'tasks.c'):

 portENTER_CRITICAL(); { xTicks = xTickCount; } portEXIT_CRITICAL(); 
+4
source share
2 answers

This is only an internal area. The advantage is that the code shows your intention in this case. For example, this scope is critical.

+5
source

There is no need to use braces like this, but it helps to read.

This is a style choice by the author, I guess :)

+4
source

Source: https://habr.com/ru/post/1299746/


All Articles