do{} while (0)
C / C++ / MFC
4
Posts
3
Posters
0
Views
1
Watching
-
I see some MFC macro use do{}while(0), for example
#define AfxOutputDebugString(lpsz) \ do \ { \ USES_CONVERSION; \ _RPT0(_CRT_WARN, W2CA(lpsz)); \ } while (0) #else
why use this kind of technique?Not anymore! Now
AfxOutputDebugstring
is defined as:#define AfxOutputDebugString TRACE
Maxwell Chen
-
I see some MFC macro use do{}while(0), for example
#define AfxOutputDebugString(lpsz) \ do \ { \ USES_CONVERSION; \ _RPT0(_CRT_WARN, W2CA(lpsz)); \ } while (0) #else
why use this kind of technique? -
Hi, the do{} while(0) is a technique to force the programmer to place a ; after the MACRO line so it looks more like a normal function then a macro
codito ergo sum