Source Insight:显示枚举值

发布于 2024-08-24 00:05:16 字数 417 浏览 2 评论 0原文

我正在使用 C 语言进行编程并使用 Source Insight。

我有一个带有很多常量(例如 100)的枚举类型。我有打印变量值的调试打印,但它们(当然)打印为整数。

我想做的是单击枚举常量的名称,然后查看其数值显示在某处。 (我已经在 Visual Studio 插件中看到了这一点,所以它一定是可能的。)

也就是说,假设我

enum colors {
    ORANGE, PURPLE, PINK
};

想单击(或选择或其他东西)PURPLE 并查看值1 可见的地方(理想情况下是符号窗口或上下文窗口,但我并不特别)。

在 Source Insight 中是否有一种简单的方法可以做到这一点?至少有困难的方法吗(例如编写宏)?

I'm programming in C and using Source Insight.

I have an enum type with a lot of constants (like 100). I have debug prints that print out variable values, but they (of course) print out as integers.

What I'd like to do is click on the name of an enum constant, and see its numeric value displayed somewhere. (I've seen this done in a Visual Studio plugin, so it must be possible.)

That is, assume I have

enum colors {
    ORANGE, PURPLE, PINK
};

I want to click on (or select, or something) PURPLE and see the value 1 somewhere visible (ideally, the symbol window or context window, but I'm not particular).

Is there an easy way to do this in Source Insight? Is there a difficult way, at least (such as writing a macro)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹂绝世的画 2024-08-31 00:05:16

我发现做到这一点的唯一方法是给枚举的每个成员一个特定的值 - 然后当它找到枚举常量时它会显示在上下文窗口中。
例如:

enum colors {
    ORANGE = 0,
    PURPLE = 1,
    PINK = 2
};

这不是很好,但它可以工作...

看起来可以编写一个宏来弹出一个带有该值的消息框,但我无法让它在 3.50.0064 中正常工作 - 它似乎认为光标下有错误的枚举。我的测试宏代码是

macro ShowEnum()
{
  symbolname = GetCurSymbol()
  symbol = GetSymbolLocation(symbolname)

  if (symbol == nil)
    Msg (symbolname # "not found")
  else
    Msg (symbolname # " found")
}

对我来说,这会从枚举列表中返回一个随机项目作为“找到”的项目。如果返回正确的值,我们可以使用 SymbolParent() 查找父级,然后使用 SymbolChildren() / SymListCount() 遍历子级

The only way I've found to do this is to give each member of the enumeration a specific value - then it shows up in the context window when it finds the enum constant.
eg:

enum colors {
    ORANGE = 0,
    PURPLE = 1,
    PINK = 2
};

It's not great but it works...

It looks like it would be possible to write a macro that popped up a message box with the value but I can't get it to work properly in 3.50.0064 - it seems to think the wrong enum is under the cursor. My test macro code is

macro ShowEnum()
{
  symbolname = GetCurSymbol()
  symbol = GetSymbolLocation(symbolname)

  if (symbol == nil)
    Msg (symbolname # "not found")
  else
    Msg (symbolname # " found")
}

For me, this returns a random item from the enum list as the "found" one. If returned the right one we could look up the parent with SymbolParent() then iterate through the children using SymbolChildren() / SymListCount()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文