1

I want to be able to write small scripts to analyze the macros, prototypes, etc., that are effectively included on the platform I am compiling on when I #include the official C header files associated with large external libraries in my C programs. (Assume I am compiling with gcc. Answers for other compilers are of interest too.)

Serious obstacles to this are recursive includes, conditional compilation directives, and the interactions between the two. So I seek a tool that will recursively find the text effectively included by processing these directives, producing a single header file, the inclusion of which is equivalent to the inclusion of the official ones for the current platform only.

(It would be very nice if in addition to supplying the conditionally relevant macros and C declarations, that comments were preserved, and #line directives inserted from time-to-time so as to indicate the origin of various parts of the output. But all of this is less than vital.)

I don't insist upon recursive output from non-top-level #includes, though to work properly, the tool will clearly have to recursively visit #included files inside the headers it is asked to pursue. So the tool could leave those lower level #include directives in its output, rather than recursively interpolating their recursively processed bodies.

Is there a tool out there that specializes header files in this fashion?

Carl Sturtivant
  • 137
  • 1
  • 3

0 Answers0