J
J Krugman
I'm trying to read some source code that makes very heavy use of
macros and other pre-processor directives. To make matters worse,
macro definitions are stacked several layers deep (i.e. macros are
defined in terms of other macros, which are in turn defined in
terms of other macros, seemingly ad infinitum).
I tried reading the *.i files generated by the preprocessor (i.e.
by giving gcc the -E flag). To my surprise, the macros were not
fully expanded in the *.i files. For example, if
#define FOO(x) 2*(x)
#define BAR(x) FOO(x)
then occurrences of BAR(x) in the *.c files where expanded only to
FOO(x) in the corresponding *.i files, not to 2*(x).
What can I do to generate source code with all the macros fully
expanded? Are there tools that are useful when attempting to read
such code?
Thanks!
jill
macros and other pre-processor directives. To make matters worse,
macro definitions are stacked several layers deep (i.e. macros are
defined in terms of other macros, which are in turn defined in
terms of other macros, seemingly ad infinitum).
I tried reading the *.i files generated by the preprocessor (i.e.
by giving gcc the -E flag). To my surprise, the macros were not
fully expanded in the *.i files. For example, if
#define FOO(x) 2*(x)
#define BAR(x) FOO(x)
then occurrences of BAR(x) in the *.c files where expanded only to
FOO(x) in the corresponding *.i files, not to 2*(x).
What can I do to generate source code with all the macros fully
expanded? Are there tools that are useful when attempting to read
such code?
Thanks!
jill