为什么我们把别的东西放在宏的最后

时间:2012-08-03 14:59:31

标签: c++

  

可能重复:
  Why are there sometimes meaningless do/while and if/else statements in C/C++ macros?

#define QL_REQUIRE(condition,message) \
if (!(condition)) { \
    std::ostringstream _ql_msg_stream; \
    _ql_msg_stream << message; \
    throw QuantLib::Error(__FILE__,__LINE__, \
                          BOOST_CURRENT_FUNCTION,_ql_msg_stream.str()); \
 } else 

如何使用它:

void testingMacros1 (){
   double x =0.0;
   QL_REQUIRE (x!=0 ," Zero number !");
}

为什么宏最终会注入else

0 个答案:

没有答案