c ++预处理器宏错误

时间:2014-08-19 12:56:37

标签: c++ macros

决定让生活更轻松我编写了以下宏来简化记录器调用:

#define LOG(level_, message_) \
    InfraLogger::instance()->log(level_, \
    boost::filesystem::path(__FILE__).filename().string(), \
    __FUNCTION__, static_cast<std::ostringstream&>(std::ostringstream().flush() << message_).str(), __LINE__ )

#define LOG_DEBUG (message_) \
    InfraLogger::instance()->log(log_debug, \
    boost::filesystem::path(__FILE__).filename().string(), \
    __FUNCTION__, static_cast<std::ostringstream&>(std::ostringstream() << message_).str(), __LINE__ )

正如您所看到的,唯一的区别在于省略level_宏中的LOG_DEBUG参数,而是使用显式枚举值。 调用如下:

LOG(log_info, "This is" << "Test message");
LOG_DEBUG("This is" << "Test message");

但是。虽然前者编译并且完美地工作,但后者给出了以下一组错误:

enter image description here

我完全陷入了这个问题(尝试使用谷歌搜索但不能确定谷歌的用途)。希望有人能说清楚。 提前致谢

0 个答案:

没有答案