[cfe-dev] how to dump/trace the include path to a previous definition

Philip Ashmore contact at philipashmore.com
Thu Nov 24 19:16:24 PST 2011


Hi there.

Is there a way to get clang to store/dump the include path to previous 
definitions/typedefs?

Saying that A, defined in file B, line C was previously defined in file 
B, line C isn't helpful.

I know, I know, "don't include the same header file twice" but I have 
good reasons to do so.

Details:

I have several projects that use header files to do the "C" equivalent 
of class template definitions.
The "templates" are things like AVL trees, and the "classes" are 
instantiations of the template with #defines standing in for template 
arguments.

This approach is currently the only way I can get multiple instances of 
the same template into a translation unit without name clashes - I wish 
there was a better way.

Unfortunately this approach isn't without its problems.

My next release will include the project files using "-I\${top_srcdir}" 
instead of "-isystem ${top_srcdir}" and this has uncovered problems now 
that the compiler knows the project include files are not system headers.

The one I'm stumped by is typedef redefinitions caused by multiple 
inclusion from the same include file.

I'm sure a solution to this problem would be of use to others too - I'm 
not the only one who uses tricks like this.

Regards,
Philip Ashmore




More information about the cfe-dev mailing list