It seems Eclipse allows user to "see the expansion Step-by-Step" by pressing F2.
似乎Eclipse允许用户通过按F2“逐步查看扩展”。
I like this awesome feature. But can I do the same thing with just gcc
or clang
(or any tool)?
我喜欢这个很棒的功能。但是我可以用gcc或clang(或任何工具)做同样的事情吗?
-E
option makes all macros fully expanded. So I haven't found any alternative way to expand macros step-by-step.
-E选项使所有宏完全展开。所以我没有找到任何替代方法来逐步扩展宏。
Eclipse is big. I hope I don't need to install it everywhere and have it launched all the time.
Eclipse很大。我希望我不需要在任何地方安装它并一直启动它。
1 个解决方案
#1
1
It's a feature built into Eclipse. If such a tool was provided as part of the GCC or Clang toolchain, Eclipse would have no need to implement it. Such a feature could be implemented as an extension to GCC using MELT. LLVM (of which Clang is a part of) is designed to make something like this trivial.
它是Eclipse内置的一个功能。如果这样的工具是作为GCC或Clang工具链的一部分提供的,那么Eclipse就不需要实现它。这样的特征可以作为使用MELT的GCC的扩展来实现。 LLVM(其中Clang是其中的一部分)旨在使这样的事情变得微不足道。
One thing you have to keep in mind that macro expansion is a tricky business. At any given point in time, a macro definition may change or not exist at all. Theoretically you could use gdb
(the debugger that comes with GCC) to step through your program to see macro expansions at different point in the program. If you want, you could try writing a gdb
plugin in Python.
有一点你必须记住,宏观扩张是一项棘手的业务。在任何给定的时间点,宏定义可能会改变或根本不存在。从理论上讲,您可以使用gdb(GCC附带的调试器)逐步执行程序,以查看程序中不同点的宏扩展。如果你愿意,你可以尝试用Python编写一个gdb插件。
#1
1
It's a feature built into Eclipse. If such a tool was provided as part of the GCC or Clang toolchain, Eclipse would have no need to implement it. Such a feature could be implemented as an extension to GCC using MELT. LLVM (of which Clang is a part of) is designed to make something like this trivial.
它是Eclipse内置的一个功能。如果这样的工具是作为GCC或Clang工具链的一部分提供的,那么Eclipse就不需要实现它。这样的特征可以作为使用MELT的GCC的扩展来实现。 LLVM(其中Clang是其中的一部分)旨在使这样的事情变得微不足道。
One thing you have to keep in mind that macro expansion is a tricky business. At any given point in time, a macro definition may change or not exist at all. Theoretically you could use gdb
(the debugger that comes with GCC) to step through your program to see macro expansions at different point in the program. If you want, you could try writing a gdb
plugin in Python.
有一点你必须记住,宏观扩张是一项棘手的业务。在任何给定的时间点,宏定义可能会改变或根本不存在。从理论上讲,您可以使用gdb(GCC附带的调试器)逐步执行程序,以查看程序中不同点的宏扩展。如果你愿意,你可以尝试用Python编写一个gdb插件。