Tagged articles
1 articles
Page 1 of 1
Liangxu Linux
Liangxu Linux
Sep 21, 2023 · Fundamentals

When to Use {} vs do{…}while(0) vs ({}) in C Function‑like Macros

This article explains the three common techniques for wrapping C function‑like macros—plain braces, do{…}while(0), and the GNU ({}) extension—detailing their syntax, usage pitfalls, advantages, disadvantages, and recommendations for safe macro design.

CGNU extensionMacros
0 likes · 8 min read
When to Use {} vs do{…}while(0) vs ({}) in C Function‑like Macros