【问题标题】:Specman e: How to print a pointer to a struct?Specman e:如何打印指向结构的指针?
【发布时间】:2018-06-18 08:50:28
【问题描述】:

我的验证环境中有下一条消息:

message(LOW, vt.text_style(LIGHT_PURPLE, " bla bla bla "), some_struct);

我得到的输出:

 bla bla bla  - some_struct-@405

我想使用appendf 字符串例程向消息中添加其他信息,但是如何打印地址some_struct-@405(或其他名称)?

我试过%x,但它导致编译错误:

message(LOW, vt.text_style(LIGHT_PURPLE, appendf(" bla bla bla %s %x ", new_info, some_struct)));

如何打印指向appendf 中的结构的指针?

感谢您的帮助

【问题讨论】:

    标签: specman e


    【解决方案1】:

    您应该只使用%s。它可以用于所有类型,甚至是结构。它实际上为相关参数调用to_string(),不管它的类型是什么。

    %x 表示十六进制格式,只能用于数字类型。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-30
      • 1970-01-01
      相关资源
      最近更新 更多