2008-06-07

while(0)の有効活用

カラwhileって使いますか?

以下のコードとの違いが良く分からない。

BOOL func( void )
{
#define break return FALSE

  if( !test1() )
  { break ; }
  if( !test2() )
  { break ; }
  if( !test3() )
  { break ; }
  if( !test4() )
  { break ; }
  if( !test5() )
  { break ; }
  testOKfunc() ; // 条件を満たせばできる処理

#undef break

  return TRUE ;
}

No comments:

Post a Comment

You can use some HTML elements, such as <b>, <i>, <a>, also, some characters need to be entity referenced such as <, > and & Your comment may need to be confirmed by blog author. Your comment will be published under GFDL 1.3 or later license with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.