Source Insight:显示枚举值
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现做到这一点的唯一方法是给枚举的每个成员一个特定的值 - 然后当它找到枚举常量时它会显示在上下文窗口中。
例如:
这不是很好,但它可以工作...
看起来可以编写一个宏来弹出一个带有该值的消息框,但我无法让它在 3.50.0064 中正常工作 - 它似乎认为光标下有错误的枚举。我的测试宏代码是
对我来说,这会从枚举列表中返回一个随机项目作为“找到”的项目。如果返回正确的值,我们可以使用 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:
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
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()