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

Matthieu Monrocq matthieu.monrocq at gmail.com
Fri Nov 25 10:43:46 PST 2011


Le 25 novembre 2011 04:16, Philip Ashmore <contact at philipashmore.com> a
écrit :

> 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
>

Is there any special reason that you would use:

#include "mytrick.h"

Instead of a regular macro invitation with arguments:

MY_TRICK()

?

Clang would deal with the latter very nicely, especially since Chandler
worked out the macro expansion in diagnostics.

-- Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111125/e7424fe5/attachment.html>


More information about the cfe-dev mailing list