返回信息流源码查看:https://www.nsnam.org/docs/release/3.18/doxygen/log_8h_source.html
问题是:第131行的代码有什么意义?强制转换后就没了?std::clog不会受到第131行的影响吧?
#define NS_LOG_APPEND_TIME_PREFIX \
126 if (g_log.IsEnabled (ns3::LOG_PREFIX_TIME)) \
127 { \
128 ns3::LogTimePrinter printer = ns3::LogGetTimePrinter (); \
129 if (printer != 0) \
130 { \
131 (*printer)(std::clog); \ //这里
132 std::clog << " "; \
133 } \
134 }
这是一条镜像帖。来源:北邮人论坛 / cpp / #94862同步于 2017/3/13
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
一个关于ns3内log系统的C++的简单问题
bond1993
2017/3/13镜像同步5 回复
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
啊,确实是函数指针调用!脑子突然抽了...
谢谢~此贴终结
【 在 chenxiansf 的大作中提到: 】
: 没点链接,我咋看着像是用函数指针调用函数呢,你确定是强制类型转换?
楼上正解,这是函数调用。
364 namespace ns3 {
365
373 void LogComponentPrintList (void);
374
375 typedef void (*LogTimePrinter)(std::ostream &os);
376 typedef void (*LogNodePrinter)(std::ostream &os);
377
378 void LogSetTimePrinter (LogTimePrinter);
379 LogTimePrinter LogGetTimePrinter (void);
380
381 void LogSetNodePrinter (LogNodePrinter);