mirror of
https://github.com/ebrandi/FDD-book.git
synced 2026-12-06 08:33:30 +00:00
fixing markdown tags
This commit is contained in:
parent
9e51e69092
commit
c7be15f162
1 changed files with 4 additions and 4 deletions
|
|
@ -1228,10 +1228,10 @@ In the FreeBSD kernel, you'll often see this pattern inside macros designed to b
|
|||
|
||||
3. `do...while (0)`: Wraps the two statements so that when this macro is used, it behaves syntactically like a single statement, even if followed by a semicolon, preventing issues in constructs like:
|
||||
|
||||
```c
|
||||
if (x) TIMESPEC_TO_TIMEVAL(tv, ts);
|
||||
else ...
|
||||
|
||||
```c
|
||||
if (x) TIMESPEC_TO_TIMEVAL(tv, ts);
|
||||
else ...
|
||||
```
|
||||
|
||||
While `do...while (0)` may look odd, it’s a solid C idiom used to make macro expansions safe and predictable in all contexts (like inside conditional statements). It ensures that the entire macro behaves like one statement and avoids accidentally creating half-executed code. Understanding this helps you read and avoid subtle bugs in kernel code that rely heavily on macros for clarity and safety.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue