오후 2:52 2007-05-25
do{}while(0)를 하는 이유
조경민 bro@shinbiro.com
===================================================


#define FOO  a = 1; printf("aa");
#define FOO  {a = 1; printf("aa");}


if( xx )
 FOO;
else
 a =2;


이런 경우 때문에 아래처럼 하는게 낫다.


#define FOO  do { a = 1; printf("aa"); }while(0)


 

'KB > C/C++' 카테고리의 다른 글

d  (0) 2007.07.30
C와 어셈블리 호출  (0) 2006.08.15
VC++.NET 새 키워드  (0) 2006.06.28
cl.exe Episode XIII: Attack of the Standards: VC6, 7에서 C++ 표준 적용 사항  (0) 2006.06.28
typeof  (0) 2006.06.28

+ Recent posts